Skip to content

Instantly share code, notes, and snippets.

@leadscloud
Forked from Takazudo/browserSniffing.js
Created August 17, 2013 04:50
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 leadscloud/6255313 to your computer and use it in GitHub Desktop.
Save leadscloud/6255313 to your computer and use it in GitHub Desktop.
/**
* browser sinffing
* http://james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/
*/
(function(){
var ie = (function(){
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
all[0]
);
return v > 4 ? v : undef;
}());
/* jQuery interface */
$.browser.ie6 = (ie === 6);
$.browser.ielt7 = (ie < 7);
$.browser.ie7 = (ie === 7);
$.browser.ielt8 = (ie < 8);
$.browser.ie8 = (ie === 8);
$.browser.ielt9 = (ie < 9);
$.browser.ie9 = (ie === 9);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment