Monday, July 25, 2011

Check whether Silverlight is installed in your system or not

Copy the below code and paste into the blank notepad file and save as "HTML" extension
after running the page click on Check Silverlight link.

<html>
<head>
<script language="javascript">
function ShowMessage()
{
 if(check()==true)
 {
  alert("SilverLight installed.");
 }
 else
 {
  alert("SilverLight Not installed.");
 }
}

function check()
{
var browser = navigator.appName; // Get browser
var silverlightInstalled = false;
if (browser == 'Microsoft Internet Explorer')
{
    try
    {
        var slControl = new ActiveXObject('AgControl.AgControl');
        silverlightInstalled = true;

 
    }
    catch (e)
    {
        // Error. Silverlight not installed.
    }
}
else
{
    // Handle Netscape, FireFox, Google chrome etc
    try
    {
        if (navigator.plugins["Silverlight Plug-In"])
        {
            silverlightInstalled = true;
        }
    }
    catch (e)
    {
        // Error. Silverlight not installed.
    }
}
return silverlightInstalled;
//alert(silverlightInstalled);
}
</script>
</head>
<body>
<a href="javascript:void(ShowMessage())">Check Silverlight</a>
</body>
</html>

No comments:

Post a Comment