How can I use javascript/jQuery/etc to detect if Flash is installed and if it isn't, display a div that contains information informing the user that they need to install flash?
8 Answers
If swfobject
won't suffice, or you need to create something a little more bespoke, try this:
var hasFlash = false;
try {
hasFlash = Boolean(new ActiveXObject('ShockwaveFlash.ShockwaveFlash'));
} catch(exception) {
hasFlash = ('undefined' != typeof navigator.mimeTypes['application/x-shockwave-flash']);
}
It works with 7 and 8.

- 26,865
- 29
- 124
- 202

- 1,981
- 2
- 13
- 13
-
2this works nice if you just want to detect if it is installed and not necessarily display a swf either way. – ctrlShiftBryan Oct 13 '10 at 20:03
-
10Had to modify this to: var hasFlash = false; try { var fo = (navigator.mimeTypes && navigator.mimeTypes['application/x-shockwave-flash']) ? navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin : 0; if(fo) hasFlash = true; }catch(e){ if(navigator.mimeTypes ['application/x-shockwave-flash'] != undefined) hasFlash = true; }" – invertedSpear May 06 '11 at 00:13
-
1that won't work on IE7, as you're not testing the activexobject part – Kevin May 27 '11 at 16:29
-
1upvote for using 5 lines of JavaScript instead of using an entire library – Alex W Jun 17 '14 at 18:30
-
This will work for android mobile browser like firefox and chrome ? – Maniprakash Chinnasamy Oct 18 '14 at 12:23
-
nice solution, but in the catch case I prefer to check : `(typeof navigator.mimeTypes['application/x-shockwave-flash'] !== 'undefined')` – zooblin Jan 17 '16 at 07:00
-
solution was not working for ubuntu14.04 firefox(44.0) but @inverrtedSpear with your changes solution worked fine. – Aameer Feb 08 '16 at 13:52
-
This is only working if the user hasn't installed Flash Player, but it's not working if it's installed but deactivated. – Jose Ignacio Hita Jul 22 '16 at 05:06
-
What if the flash is out of date ? Safari sometimes says it's out of date and it won't work until you update. How would I check for that? – trainoasis Sep 02 '16 at 08:01
@Drewid's answer didn't work in my Firefox 25 if the flash plugin is just disabled but installed.
@invertedSpear's comment in that answer worked in firefox but not in any IE version.
So combined both their code and got this. Tested in Google Chrome 31, Firefox 25, IE 8-10. Thanks Drewid and invertedSpear :)
var hasFlash = false;
try {
var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
if (fo) {
hasFlash = true;
}
} catch (e) {
if (navigator.mimeTypes
&& navigator.mimeTypes['application/x-shockwave-flash'] != undefined
&& navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin) {
hasFlash = true;
}
}

- 3,265
- 6
- 23
- 36
-
1
-
1It doesn't work if plugin are allowed but Flash is explicitely blocked for the website we are checking. Safari 8.0.8. In this case hasFlash is still true (should be false). – Eugenio Sep 07 '16 at 09:06
-
No longer works in Firefox 50+ tested 2017, still says "true" when I "block" flash from running on website. – tmarois Feb 18 '17 at 19:48
-
-
seems like it is taking up memory and not release everytime this code runs. IE11 on win 7 specifically – 1Mayur Apr 02 '19 at 20:43
Use swfobject. it replaces a div with the flash if it is installed. see: http://code.google.com/p/swfobject/
You can use navigator.mimeTypes.
if (navigator.mimeTypes ["application/x-shockwave-flash"] == undefined)
$("#someDiv").show ();

- 26,396
- 5
- 54
- 57
jqplugin: http://code.google.com/p/jqplugin/
$.browser.flash == true

- 45,514
- 58
- 177
- 257

- 7,538
- 5
- 55
- 74
You should also be able to use..
swfobject.getFlashPlayerVersion().major === 0
with the swfobject-Plugin.

- 7,825
- 7
- 37
- 48

- 41
- 2
I used Adobe's detection kit, originally suggested by justpassinby. Their system is nice because it detects the version number and compares it for you against your 'required version'
One bad thing is it does an alert showing the detected version of flash, which isn't very user friendly. All of a sudden a box pops up with some seemingly random numbers.
Some modifications you might want to consider:
- remove the alert
- change it so it returns an object (or array) --- first element is boolean true/false for "was the required version found on user's machine" --- second element is the actual version number found on user's machine

- 21
- 1
Very very minified version of http://www.featureblend.com/javascript-flash-detection-library.html (only boolean flash detection)
var isFlashInstalled = (function(){
var b=new function(){var n=this;n.c=!1;var a="ShockwaveFlash.ShockwaveFlash",r=[{name:a+".7",version:function(n){return e(n)}},{name:a+".6",version:function(n){var a="6,0,21";try{n.AllowScriptAccess="always",a=e(n)}catch(r){}return a}},{name:a,version:function(n){return e(n)}}],e=function(n){var a=-1;try{a=n.GetVariable("$version")}catch(r){}return a},i=function(n){var a=-1;try{a=new ActiveXObject(n)}catch(r){a={activeXError:!0}}return a};n.b=function(){if(navigator.plugins&&navigator.plugins.length>0){var a="application/x-shockwave-flash",e=navigator.mimeTypes;e&&e[a]&&e[a].enabledPlugin&&e[a].enabledPlugin.description&&(n.c=!0)}else if(-1==navigator.appVersion.indexOf("Mac")&&window.execScript)for(var t=-1,c=0;c<r.length&&-1==t;c++){var o=i(r[c].name);o.activeXError||(n.c=!0)}}()};
return b.c;
})();
if(isFlashInstalled){
// Do something with flash
}else{
// Don't use flash
}

- 1,001
- 1
- 10
- 18