Silverlight Plug-in

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

<object type="application/x-silverlight...>
...
</object>

Syntax Notes

The syntax shown is the object declaration in HTML. This is how you instantiate a Silverlight plug-in in a browser host. For more information, including details on the type attribute for various cases, see How to: Add Silverlight to a Web Page by Using HTML or Silverlight Plug-in Object Reference.

Events

OnError, OnFullScreenChanged, OnLoad, OnResize, OnZoom (Silverlight 3)

Managed Equivalent

The Silverlight plug-in object is an object to the HTML DOM and to its own JavaScript API, but does not have a direct equivalent in the managed API. Some of the same APIs are exposed on SilverlightHost, Content, and Settings classes, however some of these managed equivalents are not settable in the managed API even though they are settable either through the HTML DOM or JavaScript.

Remarks

You embed the Silverlight plug-in in a host HTML page. 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 in one 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.

Once you have created the Silverlight plug-in instance, you can access it and script to it either from the HTML Document Object Model (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 the GetHost method to get the object for the plug-in that contains that content.

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.

The following is a list of conceptual topics related to the Silverlight plug-in. Note that these topics are written primarily for users of the managed API, and may not have code examples or specific information that address the JavaScript API scenarios.

Example

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:

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

Any UIElement derived object can use the GetHost method 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.

// Specify the event-handler function for the 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

Reference