Created
April 25, 2013 07:39
-
-
Save tieleman/5458130 to your computer and use it in GitHub Desktop.
Two quick 'n dirty JavaScript snippets to determine whether Flash/Silverlight are installed. Wrapped in try/catch blocks to prevent IE8 from throwing errors. Uses the "navigator.plugins" object in modern browsers and ActiveXObject for old IE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hasFlash = false; | |
var hasSilverlight = false; | |
try { | |
hasFlash = !!((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) !== false)); | |
} catch(err) { | |
hasFlash = false; | |
} | |
try { | |
hasSilverlight = !!((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Silverlight Plug-In"] == "object") || (window.ActiveXObject && (new ActiveXObject("AgControl.AgControl")) !== false)); | |
} catch(err) { | |
hasSilverlight = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment