views:

37

answers:

1

Can I detect with Javascript if the client has the needed runtime to run a Silverlight section in a page, and load if if they do, otherwise leave a static image or something in that area?

I would like to add some Silverlight to a page, but it's not an important part of the page so I would rather just silently fall back to pure web standard stuff if they don't have it installed rather than putting up something that asks them to install it.

+4  A: 

The standard example page such as the one built when you run a silverlight app from visual studio handles this for you.

   <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
   <param name="source" value="SilverlightApplication1.xap"/>
   <param name="onError" value="onSilverlightError" />
   <param name="background" value="white" />
   <param name="minRuntimeVersion" value="3.0.40624.0" />
   <param name="autoUpgrade" value="true" />
   <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=3.0.40624.0" style="text-decoration:none">
    <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
   </a>
    </object>

Note that when an object tag is unable instance the object associated with the type it renders inner html present instead. So could modify the inner html to display what ever you feel is an appropriate fallback.

AnthonyWJones