How to check if javascript function from silverlight exists

How to check if javascript function from silverlight exists

+3
source share
2 answers

In silverlight code, you check for something, including the a function, using the method GetProperty: -

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

At the same time, if the name exists, but it is not a function, the above code throws an exception.

+2
source

Use the HTML bridge .

If you call HtmlPage.Window.Invoke();with a javascript method that is not there, an Invoke () call should throw an exception.

0
source

Source: https://habr.com/ru/post/1747397/


All Articles