5

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.

Gaurav Pant
  • 4,029
  • 6
  • 31
  • 54
  • I wonder if Flash even supports IE6 anymore.... – Blazemonger Jul 10 '13 at 13:08
  • ya true..on IE6 its not supported. But how to check for IE7,IE8 and IE9. – Gaurav Pant Jul 10 '13 at 13:11
  • 2
    Have you searched Google for "ie7 flash detect"? Did you try the solutions that were returned? – Blazemonger Jul 10 '13 at 13:14
  • possible duplicate of [How can I detect if Flash is installed and if not, display a hidden div that informs the user?](http://stackoverflow.com/questions/998245/how-can-i-detect-if-flash-is-installed-and-if-not-display-a-hidden-div-that-inf) – Mike Stumpf Mar 05 '14 at 13:20
  • @Mike -- it is specific to chrome.. Swfobject wont work for chrome if user has disabled the flash. – Gaurav Pant Mar 05 '14 at 14:49
  • @virus Sorry, I meant the second answer by drewid: if swfobject wont suffice, or you need to create something a little more bespoke try this. It works with 7 and 8 var hasFlash = false; try { var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); if(fo) hasFlash = true; }catch(e){ if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) hasFlash = true; } – Mike Stumpf Mar 05 '14 at 15:33

2 Answers2

3

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/

Robert Hoffmann
  • 2,366
  • 19
  • 29
2

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

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.

rtpHarry
  • 13,019
  • 4
  • 43
  • 64
  • Hye thanks..i have already used this now.But using swfobject I could not able to detect whether flash is enabled in chrome or not. For other browsers(IE(7 & 8) , Firefox it is working fine.I know i have asked specifically for IE but now my requirement is like it. thanks for your response. – Gaurav Pant Jul 10 '13 at 21:59