Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a javascript function exists from silverlight

How to check if a javascript function exists from silverlight

like image 757
zachary Avatar asked Jun 01 '26 18:06

zachary


1 Answers

In your silverlight code you check for the presence of anything including a function a with the GetProperty method:-

 var fn = HtmlPage.Window.GetProperty("myJavascriptFunction");
 if (fn != null)
     fn.InvokeSelf("Hello");

On caveat though, if the name exists but it isn't a function the above code will throw an exception.

like image 122
AnthonyWJones Avatar answered Jun 04 '26 12:06

AnthonyWJones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!