Page view counter

Silverlight Tips of the Day - Blog by Mike Snow

Game Programming with Silverlight

Silverlight Tip of the Day #79 – How to Disable HTML DOM Access from your Silverlight Application.

If you would like to disable your Silverlight application from having access to your browser DOM you can do so through the parameter called EnableHtmlAccess. For example, to disable the access in your HTML page that hosts your Silverlight component you would add this parameter to your Silverlight control in your HTML file:

<param name="enablehtmlaccess" value="false"/>

If your Silverlight application tried to call the following method to set a cookie:

private void SetCookie(string key, string value, double daysToExpire)
{
    DateTime expireDate = DateTime.Now + TimeSpan.FromDays(daysToExpire);
    string newCookie = key + "=" + value + ";expires=" + expireDate.ToString("R");
    HtmlPage.Document.SetProperty("cookie", newCookie);
}

You would get this error stating the DOM/scripting bridge is disabled:

image

Thank you,
--Mike Snow

Subscribe in a reader

Comments

Microsoft Weblogs said:

If you would like to disable your Silverlight application from having access to your browser DOM you

# January 8, 2009 8:14 PM

Dew Drop - January 9, 2009 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - January 9, 2009 | Alvin Ashcraft's Morning Dew

# January 9, 2009 11:04 AM

ramon.duraes said:

Good!! :)

# January 9, 2009 12:40 PM

Silverlight Tips of the Day - Blog by Mike Snow said:

The purpose of this post is to create an outline summary all the blogs from my Silverlight Tips of the

# January 9, 2009 2:37 PM

Community Blogs said:

In this issue: Mike Ormond, Koen Zwikstra, Andrew Duthie, Mike Snow, Terence Tsang, and Corey Schuman

# January 9, 2009 3:07 PM

Wie man HTML DOM Zugriff in der Silverlight HTML DOM Zugriff verbietet. at Programming with Silverlight, WPF & .NET said:

Pingback from  Wie man HTML DOM Zugriff in der Silverlight HTML DOM Zugriff verbietet. at Programming with Silverlight, WPF &amp; .NET

# January 14, 2009 7:51 AM

Visual Web Developer Team Blog said:

Most Recent Posts: Tip #93 - Reading XML with Silverlight Tip #92 - How to Load Images from a Stream

# February 10, 2009 6:25 PM