How to check if a javascript function exists from silverlight
A:
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.
Dave Swersky
2010-05-27 16:09:45
In the javascript
zachary
2010-05-27 17:49:52
+2
A:
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.
AnthonyWJones
2010-05-27 21:21:14