Javascript – How to detect if Flash Player is disabled in a browser using JavaScript

clientflashjavascript

I know how to detect if Flash player is installed in a browser. I'm using the hasFlashPlayerVersion() function of swfobject for that. However, I can't seem to find any documentation on how to detect if the plug-in is installed and just disabled. I didn't see any documentation in the Flash Player Detection Kit that checks if the plug-in is enabled either.

Best Answer

I agree with Ape and have done something similar a LONG time ago with a page that said something like "detecting flash player..." and waited 20 seconds while a swf file would load and immediately redirect the browser off the page.

If the timer expired (the swf never loaded), it would prompt the user to install Flash.

It would be possible to combine that approach with the swfobject hasFlashPlayerVersion() function you mentioned. If they have flash but the swf never loads, then it's fairly safe to assume that flash is disabled.

So, there's really only 3 options:

  • No Flash
  • Flash: Enabled
  • Flash: Disabled

In pseudo code, that could look like the following:

var hasFlash = detectFlashPlayerInstalled();
var flashEnabled = false;

/* attempt to load the swf file then wait for some time, then... */

var isDisabled = hasFlash && !flashEnabled;

That works along with javascript functions like:

function flashAlive() {
    flashEnabled = true;
}
function detectFlashPlayerInstalled() { 
    //TODO: detect flash in a better way, this will do for now
    return swfobject.hasFlashPlayerVersion(VERSION);
}

called from a tiny swf file containing:

getURL("javascript:flashAlive();");

I hope that helps in some way.