How can I detect if Flash Player is disabled in a

2020-03-04 09:22发布

问题:

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.

回答1:

You could make a javascript call in an invisible swf that communicates with the browser's javascript. If a timeout occurs, then it is because the browser does not have flash player installed, or the flash player has been disabled.

getURL("javascript:jsfunction();");


回答2:

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.



回答3:

Here is a nice library I'm using: http://www.featureblend.com/javascript-flash-detection-library.html



回答4:

I don't think it is possible to detect if flash is installed but disabled.

If someone disables Flash, they might not want to tell if it's just disabled or not installed at all. Therefore a browser just tells you it is 'not available'.