Zero to Hero: How to Check if Silverlight is installed.

Technorati Tags: Silverlight

del.icio.us Tags: Silverlight

I've been getting lots of questions on how to check to see if Silverlight is already installed. This is actually very easy to do, but has somehow slipped through the cracks (I even missed it when writing my Silverlight book -- DOH!) -- anyway -- the Silverlight.js library offers how to do this as well as lots of other goodies.

First, you can check to see if Silverlight is installed by looking at the

 Silverlight.available

variable. Simple, huh? This will return true is Silverlight is installed and false if not.

While you're doing that, you may also want to see what browser and OS you are currently running.

 

The Browser is checked using this JavaScript var:

 Silverlight.ua.Browser

which will return one of the following values: 'MSIE', 'Firefox', 'Safari' or 'Unsupported'.

 

The Operating System is checked using this JavaScript var:

 Silverlight.ua.OS

which will return one of the following values: 'Windows', 'MacPPC', 'MacIntel', 'Unsupported'

 

So, using these values, you can make your installation experience as flexible as possible :)

Also, don't forget about the inplaceInstallPrompt property on the control itself.