1. 01. Incoming
  2. 02. Hifi
  3. 03. Lofi
  4. 04. The Lab
  5. 05. Tags

frequency decoder

Testing for IE with JavaScript

Posted Tuesday January 22, 2008

frequency decoder

A quick method to test for IE in JavaScript using conditional compilation

A quick one-liner that tests if the browser is Internet Explorer (Windows); useful if you have functions/methods only applicable to the beast in question:

 
 if (!/*@cc_on!@*/0) { return; };
 // IE code goes here...
 

For those of you wondering, the extra exclamation mark within the conditional compilation statement (cc_on!) double negates (!!) the zero, which means only Internet Explorer will return a value of FALSE for the condition.

Of course, it can also be used within an if … else situation:

 
 if (!/*@cc_on!@*/0) { alert("not IE"); }
 else { alert("IE"); }
 

Short but quite sweet.

Tags: No tags currently assigned

Previous Comments ~

No comments have been posted yet – comments are open though, so you can start the conversation if you so desire…

A penny for your thoughts…

Remember: Off-topic or dumb-ass comments will, of course, be deleted. Spammers shall have the scary flying-monkeys from “The Wizard of Oz” dispatched to their abode.

Popular Frequencies

  • Unobtrusive Table Sort Script (revi…
    Saturday September 16, 2006
  • Unobtrusive Date-Picker Widget Upda…
    Monday October 02, 2006
  • Unobtrusive Table Sort Script
    Friday November 18, 2005
  • Unobtrusive Date-Picker Widgit
    Friday October 14, 2005
  • Unobtrusive Table Actions Script
    Thursday November 15, 2007
All articles