Skip to content

Instantly share code, notes, and snippets.

@barneycarroll
Created August 7, 2012 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barneycarroll/3285152 to your computer and use it in GitHub Desktop.
Save barneycarroll/3285152 to your computer and use it in GitHub Desktop.
Browser feature inference
browser = {
ieVersion: function () {
var undef;
var v = 3;
var div = document.createElement('div');
var all = div.getElementsByTagName('i');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', all[0]);
return v > 4 ? v : undef;
},
hasFlash: function () {
try {
return new ActiveXObject('ShockwaveFlash.ShockwaveFlash') ? true : false;
} catch (e) {
return navigator.mimeTypes["application/x-shockwave-flash"] !== undefined ? true : false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment