Friday, November 14, 2008

Tutor.com Classroom How-To #10: manually detecting and installing the Silverlight plug-in

These How-To tips are taken from The Tutor.com Classroom: Architecture and techniques using Silverlight, WPF, and the Microsoft .NET Framework.

You can check out the Silverlight Tutor.com Classroom in "practice" mode, although the real experience is with a live tutor on the other side!

Use the isInstalled() function provided by Silverlight.js:


<script language="javascript" type="text/javascript">

Silverlight.InstallAndCreateSilverlight = function(version)
{
var retryTimeout = 1000; //the interval at which instantiation is attempted(ms)
if (Silverlight.isInstalled(version))
{
...
}
else if (!Silverlight.isInstalled(version))
{
TimeoutDelegate = function()
{
Silverlight.InstallAndCreateSilverlight(version);
}

setTimeout(TimeoutDelegate, retryTimeout);
}
}

Silverlight.InstallAndCreateSilverlight('2.0.30923.0');

</script>

No comments: