views:

2199

answers:

3

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?

+7  A: 

use swfobject. it replaces a div with the flash if it is installed. see http://code.google.com/p/swfobject/ Josh

Josh
+1  A: 

You can use navigator.mimeTypes.

if (navigator.mimeTypes ["application/x-shockwave-flash"] == undefined)
    $("#someDiv").show ();
AlbertEin
-1 Does not seem to work in IE7.
Josef
+1  A: 

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;
}
Drewid
this works nice if you just want to detect if it is installed and not necessarily display a swf either way.
ctrlShiftBryan