admin管理员组

文章数量:1327849

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.

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.

Share Improve this question edited Jul 10, 2013 at 22:00 Gaurav Pant asked Jul 10, 2013 at 13:04 Gaurav PantGaurav Pant 4,2096 gold badges32 silver badges55 bronze badges 6
  • I wonder if Flash even supports IE6 anymore.... – Blazemonger Commented Jul 10, 2013 at 13:08
  • ya true..on IE6 its not supported. But how to check for IE7,IE8 and IE9. – Gaurav Pant Commented Jul 10, 2013 at 13:11
  • 2 Have you searched Google for "ie7 flash detect"? Did you try the solutions that were returned? – Blazemonger Commented Jul 10, 2013 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? – Michael Brittlebank Commented Mar 5, 2014 at 13:20
  • @Mike -- it is specific to chrome.. Swfobject wont work for chrome if user has disabled the flash. – Gaurav Pant Commented Mar 5, 2014 at 14:49
 |  Show 1 more ment

2 Answers 2

Reset to default 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/nQ7fk/

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

  • http://code.google./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 pliant way.

本文标签: javascripthow to check flash player is installed and enabled or not in IE and ChromeStack Overflow