Appendix A. Silverlight JavaScript Reference

Using the Silverlight Plug-in

There are two ways to access the Silverlight plug-in. One is to use the HTML DOM and the document.getElementById() method, and provide the ID used in the createSilverlight() function. The other is to intercept any Silverlight event and access the plug-in in the following fashion:

function eventHandler(sender, eventArgs) {
  var plugin = sender.getHost();
}

From the plug-in, you have access to the following properties and methods:

content.accessibility

Accessibility information of the Silverlight content (read-only).

content.actualHeight

The height of the Silverlight content (read-only).

content.actualWidth

The width of the Silverlight content (read-only).

content.createFromXaml(xamlContent, nameScope)

Creates a Silverlight object with the given XAML content; if nameScope is set to true, a unique x:Name attribute is assigned.

content.createFromXamlDownloader(downloader, part)

Creates a Silverlight object from the given downloader object; if the downloaded content is a ZIP archive, part defines the name of the file to use.

content.findName(objectName)

Returns a reference to the object with the given name.

content.fullScreen

Whether the Silverlight plug-in is in full-screen mode (read and write).

content.onFullScreenChange

Event handler that is fired when the application enters or leaves full-screen mode.

content.onResize

Event handler that is fired if the Silverlight content area is resized.

createObject(objectType)

Creates and returns ...

Get Essential Silverlight 2 Up-to-Date now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.