Friday, August 15, 2008

Embeding Silverlight control in web page OBJECT versus EMBED

When deploying a Silverlight control on a web page, there are several options available. You can either use the asp:Silverlight control or embed the control into your HTML using either the OBJECT or EMBED HTML tags.

One interesting gotcha that I ran into was when I tried to instantiate the Silverlight plug-in using the OBJECT tag in Firefox 3.0. The plug-in would just not load, which is strange, because before I updateded to Silverlight Beta 2 everything seemed to work fine. After poking around, I found that Apple's Safari web browser doesn't currently support the OBJECT element. Instead you have to use the EMBED tag, which works equally well in IE and Firefox. Perhaphs Microsoft is playing to the lowest common denomentor in an attempt to keep Silverlight 100% cross-browser compliant?

Either way, if you use the EMBED tag to instantiate the Silverlight plug-in, there are a couple of things to take note of:
  1. Custom parameters that are defined as individual
  2. Alternative content that displays when the Silverlight plug-in is missing will need to be wrapped in a NOEMBED element.
Here are 2 seperate implementations of a Silverlight control. One using OBJECT tag and the other using the more compliant EMBED tag.

OBJECT Implementation

<object type="application/x-silverlight" id="silverlightControl" width="390" height="100">
<param name="background" value="Yellow">
<param name="source" value="Chapter1.xaml">
<!-- Alternative content: -->
This content requires Silverlight.
<a href="http://www.microsoft.com/silverlight/downloads.aspx">
Get it Here.</a>
</object>

EMBED Implementation

<embed type="application/x-silverlight" id="silverlightControl" width="390" height="100" background="Yellow" source="Chapter1.xaml">
<noembed>
<!-- Alternative content: -->
This content requires Silverlight.
<a href="http://www.microsoft.com/silverlight/downloads.aspx">Get it here.</a>
</noembed>
</embed>

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home