Skip to content

Instantly share code, notes, and snippets.

@tieleman
Created April 25, 2013 07:39
Show Gist options
  • Save tieleman/5458130 to your computer and use it in GitHub Desktop.
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.
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