Check if Silverlight is available on the browser? Detect if Silverlight is Installed !!

Though its 2020, and its time the cutting edge JavaScript libraries and frameworks are dominating the web market space. There are still some legacy code still using the .NET Frameworks and somewhere kept still in use and no one dare to affect the running business and why should one invest on something which is still capable of running. We would discuss the pros and cons of this in my different blog.

So, if you are the one still supporting this kind on application, and what to check in your client browser supports Silverlight or not here is a piece of code that would save you.

function checkSilverlightInstalled()
{
    var isSilverlightInstalled = false;
    try
    {
       //check on IE
       try
       {
            var slControl = new ActiveXObject('AgControl.AgControl');
            isSilverlightInstalled = true;
       }
       catch (e)
       {
        //either not installed or not IE. Check Firefox
         if ( navigator.plugins["Silverlight Plug-In"] )
         {
            isSilverlightInstalled = true;
         }
       }
    }
    catch (e)
    {
        //we don't want to leak exceptions. However, you may want
        //to add exception tracking code here.
    }


    return isSilverlightInstalled;
}

One response to “Check if Silverlight is available on the browser? Detect if Silverlight is Installed !!”

  1. Thanks man. This actually saved me. I was looking for this code but was not able to find this piece which work perfect for browser to check if silverlight exists

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: