HTML Object Element in Silverlight Application

Introduction

This Blog introduced the HTML Object Element in silverlight application. 

The object element enables you to embed and configure the Silverlight plug-in in your HTML in a way that is compatible with all supported browsers. 

An alternative to using the object element is to use the JavaScript embedding functions provided by the Silverlight.js helper file. 

Accomplish the following common tasks using the object element. 

. Embed the Silverlight plug-in and specify the application to host.
. Specify alternate HTML to display when Silverlight is not installed. 
 
Explanation 

<object width="300" height="300"
    data="data:application/x-silverlight-2,"
    type="application/x-silverlight-2" >
    <param name="source" value="SilverlightApplication1.xap"/>
</object> 

1. Width Attributes: 
  • Specifies the initial width of the Silverlight plug-in area in the HTML page.
  • Can be as a pixel value or as a percentage. For example, "400" specifies 400 pixels, and "50%" specifies 50% (half) of  the available width of the browser content area. 

2. Height Attributes
  • Specifies the initial height of the Silverlight plug-in area in the HTML page. \Can be set either as a pixel value or a percentage.For example, "300" specifies 300 pixels, and "50%" specifies 50% (half) of the available height of the browser content area. 
The width and height attributes are required for cross-browser compatibility.

3. type attribute

Identifies the Silverlight plug-in codebase. This should be set to the following value: application/x-silverlight-2 .This value uses the Silverlight MIME type to identify the plug-in and the required version.  The indicated MIME type is used with Silverlight version 2 and all later versions. 

4. data attribute

The data attribute and its value are recommended to avoid performance issues on some browsers.  The trailing comma in the data value. This indicates a second data parameter that has an empty value.
 Not used by most browsers for Silverlight purposes.

 data:application/x-silverlight-2, . 

5. Param element 

The param element named source is required, and indicates the location and name of your application file.