Thursday, November 6, 2008

Exception: The DOM/scripting bridge is disabled

Silverlight throws this error if you try and navigate the hosting browser page without setting permissions explicitly.

My calling code in C# looked like this:

HtmlPage.Window.Navigate(new Uri(url), "_top");


Stopping this exception can be done according to MSDN by setting the correct flags.

I was doing this in javascript, using the silverlight.js functions - I just had to add it to the calling code:


var properties = { width: slWidth, height: slHeight, version: "2.0.31005.0", enableHtmlAccess: "true" };
var events = { };
var initParams = params;
Silverlight.createObject(source, parentElement,
callbackId, properties, events, initParams);


In the above excerpt I had to add the "enableHtmlAccess" to "true", note that setting it to true without quotes does not work!

No comments: