I am running a DotNetNuke CMS website built on ASP.NET framework.
I have a few scripts in my page skin that I do not want to run on IE8 and below. I've been google'ing around, and I've found this IE conditional statement.
<![if gt IE 8]>
As per .85%29.aspx , this snippit should include the code inbetween for any browser that is greater than IE8. I attempted to use this conditional statement in the following manner:
<![if gt IE 8]>
<script type="text/javascript" src="//s7.addthis/js/300/addthis_widget.js#pubid=ra-4f21643b21c50811"></script>
<![endif]-->
However, this does not seem to work, and the scripts do not run on any browser. Is there a better way to acplish this goal? Is there a syntax error in my code?
Thanks for your help! Alex
I am running a DotNetNuke CMS website built on ASP.NET framework.
I have a few scripts in my page skin that I do not want to run on IE8 and below. I've been google'ing around, and I've found this IE conditional statement.
<![if gt IE 8]>
As per http://msdn.microsoft./en-us/library/ms537512%28v=vs.85%29.aspx , this snippit should include the code inbetween for any browser that is greater than IE8. I attempted to use this conditional statement in the following manner:
<![if gt IE 8]>
<script type="text/javascript" src="//s7.addthis./js/300/addthis_widget.js#pubid=ra-4f21643b21c50811"></script>
<![endif]-->
However, this does not seem to work, and the scripts do not run on any browser. Is there a better way to acplish this goal? Is there a syntax error in my code?
Thanks for your help! Alex
Share Improve this question asked Aug 20, 2013 at 21:55 Alex RitterAlex Ritter 1,0413 gold badges18 silver badges44 bronze badges 2- It will work in IE 9, but IE 10 stopped supporting conditional ments. msdn.microsoft./en-us/library/ms537512(v=vs.85).aspx . You can use conditional pilation, that is supported in all versions. Here's a post about it: stackoverflow./questions/16135814/check-for-ie-10/… – Ian Commented Aug 20, 2013 at 21:58
-
Check your syntax:
<!--[if gt IE 8]> ... <![endif]-->
– elclanrs Commented Aug 20, 2013 at 21:59
3 Answers
Reset to default 3The conditional ment should be:
<!--[if IE 8]>
<script type="text/javascript" src="//s7.addthis./js/300/addthis_widget.js#pubid=ra-4f21643b21c50811"></script>
<![endif]-->
with the two dashes after the exclamation point.
It's called a "conditional ment" because it's actually an HTML ment:
<!-- this is a ment -->.
Internet Explorer (until IE9) makes an exception and parse the ments with the special format
<!--[ if ... ]
...
<![endif]-->
as an instruction, but for any other browsers is just a ment and it'll be ignored.
Just wanted to add some updated information that as of IE10 and above, conditional ments are not supported, so using a conditional like so,
<!--[if gt IE 8]>
<script type="text/javascript" src="//s7.addthis./js/300/addthis_widget.js#pubid=ra-4f21643b21c50811"></script>
<![endif]-->
which includes a gt operator (per question post), means the script will actually only show up in IE9, effectively making it the same in function as writing:
<!--[if IE 9]>
<script type="text/javascript" src="//s7.addthis./js/300/addthis_widget.js#pubid=ra-4f21643b21c50811"></script>
<![endif]-->
End of conditional support article: https://msdn.microsoft./en-us/library/ie/hh801214%28v=vs.85%29.aspx
Conditional ments resource: https://msdn.microsoft./en-us/library/ms537512%28v=vs.85%29.aspx
Just adding an information to load different scripts for IE10+ and IE9-.
<!--[if lt IE 10]>
<script src="scripts/jquery-1.x.x.min.js" type="text/javascript"></script>
<!--<![endif]-->
<!--[if gte IE 10]><!-->
<script src="jquery-2.x.x.min.js" type="text/javascript"></script>
<!--<![endif]-->
Note the code at line 4, this informs IE10+ that the script tag at line 5 is not a ment
The above conditional statement will load jquery-1.x.x in IE9 or lower and loads jquery-2.x.x for IE10+ versions.