How to detect the Internet Explorer version in Javascript - CSS3 Examples

How to detect the Internet Explorer version in Javascript

Written by jon on 11:14 AM

It's very easy:

var ieVer=/*@cc_on function(){ switch(@_jscript_version){ case 1.0:return 3; case 3.0:return 4; case 5.0:return 5; case 5.1:return 5; case 5.5:return 5.5; case 5.6:return 6; case 5.7:return 7; }}()||@*/0;

/*@cc_on opens the conditional, while @*/ closes it. The code inside conditional comment is only read by Internet Explorer.

The code inside conditional comment establishes that every Internet Explorer version returns a number. The 0 number is outside of the conditional comment, so that other browsers will take 0 value.

If we want a desired function works only in Internet Explorer 6 and older we write a condition which requires an equal or lower to 6 value for the ieVer value:

if (ieVer<=6) {executedFunction();}

Related Posts by Categories



Widget by John | Interviewghost
  1. 0 comments: Responses to “ How to detect the Internet Explorer version in Javascript ”

RECENT COMMENTS

SUBSCRIBE TO CSS3 EXAMPLES

 Subscribe to css3 Examples via RSS
Or, subscribe via email:
Find CSS3 Examples Entries :