Export (0) Print
Expand All

Settings.EnableHTMLAccess Property

Silverlight

Gets a value that indicates whether the Silverlight plug-in allows hosted content or its runtime to access the HTML DOM.

Namespace:  System.Windows.Interop
Assembly:  System.Windows (in System.Windows.dll)

'Declaration
Public ReadOnly Property EnableHTMLAccess As Boolean

Property Value

Type: System.Boolean
true if hosted content can access the browser DOM; otherwise, false.

This property gets its value from the Silverlight plug-in configuration. For more information, see How to: Add Silverlight to a Web Page by Using HTML.

When this property is false, the HTML DOM bridge APIs are disabled. For more information about the bridge APIs, see HTML Bridge: Interaction Between HTML and Managed Code.

Caution noteCaution:

When a host page enables HTML access, it allows the Silverlight-based application complete access to its DOM, including the ability to modify content, insert and evaluate JavaScript code, and so on. This should be allowed only if the host page trusts the Silverlight-based application. HTML access is enabled by default for same-domain Silverlight-based applications because there is implicit trust between HTML and same-domain Silverlight content. However, access must be specifically enabled for cross-domain applications. For more information, see Security Settings in HTML Bridge.

The following code example demonstrates how to use this property.


' The Host object, which represents the host Silverlight plug-in. 
Dim host As System.Windows.Interop.SilverlightHost = _
    Application.Current.Host

' The following code demonstrates how to use the Host object 
' to access other APIs in the System.Windows.Interop namespace. 

' The IsVersionSupported method. This method is useful when 
' you want to implement an upgrade experience in managed code. 
Dim isSupported As Boolean = host.IsVersionSupported("2.0.30908.0")

' Read-only properties of the Host object. 
Dim pluginBackground As System.Windows.Media.Color = host.Background
Dim loaded As Boolean = host.IsLoaded
Dim source As Uri = host.Source

' The Settings object, which represents Web browser settings. 
Dim settings As System.Windows.Interop.Settings = host.Settings

' Read/write properties of the Settings object. 
settings.EnableFrameRateCounter = True
settings.EnableRedrawRegions = True
settings.MaxFrameRate = 60

' Read-only properties of the Settings object. 
Dim windowless As Boolean = settings.Windowless
Dim htmlAccessEnabled As Boolean = settings.EnableHTMLAccess

' The Content object, which represents the plug-in display area. 
Dim content As System.Windows.Interop.Content = host.Content

' The read/write IsFullScreen property of the Content object. 
' See also the Content.FullScreenChanged event. 
Dim isFullScreen As Boolean = content.IsFullScreen

' Read-only properties of the Content object. These properties do 
' not contain meaningful values until after the Content.Resized 
' event occurs for the first time. 
Dim actualWidth As Double = content.ActualWidth
Dim actualHeight As Double = content.ActualHeight


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft