Skip to content

Instantly share code, notes, and snippets.

@davidchase
Last active December 16, 2015 12:28
Show Gist options
  • Save davidchase/5434500 to your computer and use it in GitHub Desktop.
Save davidchase/5434500 to your computer and use it in GitHub Desktop.
Quick no dependency test for flash players installed... to test in chrome disable flash in chrome://plugins/ and console.log the variable "hasFlash"

Has Flash?

Test the user to see if they have flash player installed on their machine.

Vanilla JS no dependcies

Can be test in Chrome by simple disabling flash inside plugins like so:

In the address chrome://plugins/ then select Disable under Adobe Flash player.

The hasFlash variable will return false, otherwise if its enabled the hasFlash variable will return true.

Similar approach can be on other browsers as well.

var hasFlash = false;
try {
var f = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
if(f) hasFlash = true;
}catch(e){
if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) hasFlash = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment