-
-
Save getify/675496 to your computer and use it in GitHub Desktop.
var _flash_installed = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) != false)); |
If anyone is looking for @jdalton's link target, you can see its archived version here: http://web.archive.org/web/20100710000820/http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html
Also, this appears to be the most stable version I've encountered: https://code.google.com/p/doctype-mirror/wiki/ArticleDetectFlash#The_code
Don't use this code; it fails in IE8. If flash is uninstalled, IE8 fails with "Automation server can't create object" error thrown. If flash is installed, IE8 fails anyway with "Object doesn't support this property or method" which I've isolated to the usage of the !=
operator instead of !==
which does work. Either way, this cannot be reduced to a simple expression because the error is being thrown. It must be rewritten with some try/catch logic.
Best version so far is a slightly modified version of chustedde
's code but with an !== false
check instead of != false
:
var ie_flash; try { ie_flash = (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) !== false) } catch(err) { ie_flash = false; } var _flash_installed = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || ie_flash); _flash_installed;
The last _flash_installed;
statement is to have the JS console report the final result. Without it, Chrome, for example, would report "undefined".
See my gist at https://gist.github.com/JamesDunne/174ebedbc9afaf2078a7
Am facing an issue with latest Firefox 55 (win64). navigator.plugins is not returning "Shockwave Flash" even though flash is installed.
Could anyone suggest how to resolved this.
Thanks,
The test in SWFObject is not
if (window.ActiveXObject....)
but
if (typeof window.ActiveXObject !='undefined' .....)