Skip to content

Instantly share code, notes, and snippets.

@rmetzler
Forked from kahlil/detectIE.js
Created August 19, 2010 12:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmetzler/537764 to your computer and use it in GitHub Desktop.
Save rmetzler/537764 to your computer and use it in GitHub Desktop.
/*
From: http://devoracles.com/the-best-method-to-check-for-internet-explorer-in-javascript
"I declared a new variable, called IE, which has the value a comment block followed by ‘false‘.
The above variable will be understood by IE: var IE = !false, because Internet Explorer uses
JScript — a Javascript-like dialect of the standard ECMAScript — instead of Javascript which is
used by all the other browsers. JScript can parse the comments, just like Internet Explorer (see
conditional HTML comments post). This is a unique feature of IE, none of the other browsers can do it,
so Firefox, Chrome, Safari, Opera, all will understand the above declaration as IE = false."
*/
var IE = /*@cc_on!@*/false;
if (IE) {
// do things for IE
}
else {
// do things for other browsers
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment