开发者

How to check if a javascript function exists from silverlight

开发者 https://www.devze.com 2023-01-01 11:45 出处:网络
How to check if a javascript functio开发者_如何学Gon exists from silverlightIn your silverlight code you check for the presence of anything including a function a with the GetProperty method:-

How to check if a javascript functio开发者_如何学Gon exists from silverlight


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.


Use the HTML Bridge.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消