Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to check flash player is installed and enabled or not in IE and Chrome

I need to check whether Flash player is installed and enabled or not in IE/Chrome.

((typeof navigator.plugins != 'undefined' && typeof navigator.plugins['Shockwave Flash'] == 'object') || (window.ActiveXObject && (new ActiveXObject('ShockwaveFlash.ShockwaveFlash')) != false));

and

!!(navigator.mimeTypes["application/x-shockwave-flash"] || window.ActiveXObject && new ActiveXObject('ShockwaveFlash.ShockwaveFlash'));

Both are fine for all the browsers in all OS except Chrome.For chrome it gives true even if I disable the Flash Player. But for IE it is behaving differently on different systems also not working in IE6 at all. How to check for IE/Chrome if flash is installed and enabled or not.

like image 503
Gaurav Pant Avatar asked Jul 10 '13 13:07

Gaurav Pant


2 Answers

Too tired to write up a whole thing, so here is a fiddle with some flash/silverlight detection i wrote a while back. Feel free to play with it and remove the silverlight part if you don't need it.

It basically boils down to looping through all plug ins like this:

function get (name) {
    for (var i = 0, l = navigator.plugins.length; i < l; i++)
    {
        if (navigator.plugins[i].name === name) {
            return navigator.plugins[i];
        }
    }
    return undefined;
}

http://jsfiddle.net/nQ7fk/

like image 191
Robert Hoffmann Avatar answered Oct 18 '22 23:10

Robert Hoffmann


I guess you might have already ruled this out but I would recommend using swfobject to manage your flash insertion:

  • http://code.google.com/p/swfobject/

It does have features that let you detect if flash is installed and it also can trigger the installation process and manage your general flash insertion in a cross-browser, standards compliant way.

like image 36
rtpHarry Avatar answered Oct 18 '22 22:10

rtpHarry