Do not load script in IE6 or less

How can I add a condition so that if the user runs IE6 or less, so as not to load javascript. I tried the following, and <script> does not load in any browser:

 <!--[if gt IE 6]> <script blah blah blah... /> <![endif]--> <!--[if ! IE 6]> <script blah blah blah... /> <![endif]--> <!--[if !IE 6]> <script blah blah blah... /> <![endif]--> 

Some help would be greatly appreciated.

+4
source share
5 answers

Try the following:

 <!--[if gt IE 6]><!--> <script blah blah blah... /> <!--<![endif]--> 

The syntax above (with additional comment delimiters) is explained in this post .

+10
source

Have you tried head.js ? You can load this first and wrap the actual script load in a state, for example:

 <script> if(!isIE6) { head.js("path/to/script1.js", "path/to/script2.js"); } </script> 
+3
source

Use double negatives to exclude scripts from a specific version of IE

 <!-- disabled all javascript in IE6 --> <!--[if gt IE 6]><!--> <script type="text/javascript"> // special not IE6 stuff </script> <!--<![endif]--> 

Use a simple check to run scripts only on IE6

 <!--[if lte IE 6]> <script type="text/javascript"> // special IE6 stuff </script> <![endif]--> 
+2
source

Let it read should help.

http://www.quirksmode.org/css/condcom.html

I only ever used [if IE 6], but it worked fine.

0
source

Just download the script for IE 7 and above.

 <!-- [if gte IE 7]> <script type="text/javascript"> </script> <![endif]--> 

MSDN Link.

0
source

All Articles