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.
精彩评论