Export (0) Print
Expand All

Silverlight Plug-in Object

Represents a Silverlight plug-in instance that is hosted in an HTML page.

Scripting (Instantiation)

-or-

Scripting (Runtime)
See Remarks.

Remarks

You embed the Silverlight plug-in within a host HTML page. See Instantiating a Silverlight Plug-in (Using CreateSilverlight.js and Silverlight.js) and Silverlight Object Positioning for more information.

When you install the Silverlight runtime components, you install a browser plug-in that exposes a Silverlight object model for scripting. Silverlight content is displayed within or more Silverlight plug-in instances that are defined on an HTML page. The Silverlight plug-in is packaged differently on the supported platforms. Internet Explorer on Windows uses an ActiveX model to host Silverlight plug-in instances, while other browser and platform combinations use the Netscape plug-in technology to host Silverlight plug-in instances. For more information, see Instantiating a Silverlight Plug-in (Using CreateSilverlight.js and Silverlight.js) and Silverlight Object Models and Scripting to the Silverlight Plug-in.

The following illustration shows the relationship of the Web page, a single hosted Silverlight plug-in, and its content.

Relationship of Web page to Silverlight content

Relationship of Web page to Silverlight content

HTML DOM vs Siverlight Scripting Object Model

Once you have created the Silverlight plug-in instance, you can access it and script to it either from the HTML DOM of the surrounding HTML, or from the Silverlight object model once you have an entry point, such as an event handler. From within any object that is part of the Silverlight content, you can call GetHost to get the object for the plug-in that contains that content. For more information, see Silverlight Object Models and Scripting to the Silverlight Plug-in.

Instantiation Parameters vs Object Model Topology for the Silverlight Plugin

The properties of the Silverlight plug-in that you use for scripting have a different topology than the parameters that you use for instantiation. In particular, many of the properties for scripting, as well as some methods and events, are grouped under the sub-objects content and settings. For more information about the sub-objects and scripting to methods and properties of the Silverlight plug-in, see Silverlight Object Models and Scripting to the Silverlight Plug-in.

Examples

The following JavaScript example shows how to retrieve the id value of the Silverlight plug-in from the HTML DOM by using the document.getElementById method:

JavaScript
var plugin_1 = document.getElementById("SLPlugin_1");

Using the GetHost Method

The GetHost method can be used by any UIElement-derived object to retrieve the Silverlight plug-in instance that contains the object. This method is especially useful for retrieving the Silverlight plug-in in an event handling function, in which the sender parameter often identifies a UIElement-derived object.

The following JavaScript example shows how to get a reference to a Silverlight plug-in in a Loaded event handler function:

JavaScript
// Event handler function for Loaded event.
function onLoaded(sender, eventArgs)
{
    // Retrieve a reference to the plug-in.
    var slPlugin = sender.getHost();

        // Determine whether the 1.0 version of Silverlight is available.
        alert("Silverlight 1.0: " + slPlugin.isVersionSupported("1.0"));
}

See Also

Silverlight Object Models and Scripting to the Silverlight Plug-in
Instantiating a Silverlight Plug-in (Using CreateSilverlight.js and Silverlight.js)
Silverlight Object Positioning
Referencing and Modifying Silverlight Objects
Writing Event Handlers for the Silverlight Instantiation OnLoad Event
GetHost

Community Additions

Show:
© 2014 Microsoft