0

I need to check if ie 6 and if so load all js files locally or else anything higher or difference ie chrome etc then load from cdn (google, or any other)

I am already using conditional comments for styles

<!--[if lte IE 6]>          
     <link href="Content/themes/bootstrap/css/bootstrap-ie6.css" rel="stylesheet" />         
     <link href="Content/Site-ie6.css" rel="stylesheet" /> 
<![endif]-->

But i know that we have a number of users using ie6 and all those users are in the same location and need to load js files from the site not cdn's. So if ie6 load js files from local site, else anything else load from cdn.

How can i do this?

Would the below work:

similar to: (How do I make an "else" in an IE HTML conditional?)

<!--[if lte IE 6]>
  You're using IE 6!
<![endif]-->
<![if ! lte IE 6]>
  You're using something else!
<![endif]>

Thanks

Community
  • 1
  • 1
Jonnymaboy
  • 543
  • 2
  • 4
  • 18
  • I think this `Something else` would work. I am not sure about whether that `! lte IE 6` syntax is correct or not. There are some samples in this [wiki link](http://en.wikipedia.org/wiki/Conditional_comment). And finally, I totally agree with the below comment and duffymo's answer. – Harry Sep 01 '13 at 14:41
  • 2
    user modernizr please – kangoroo Sep 01 '13 at 14:44
  • I do have <%: Scripts.Render("~/bundles/modernizr") %>. but to be honest i haven't even checked where that comes from or what it does. Again though if its a cdn then it wont work for these particular ie6 users. The ie6 users have a firewall blocking access to everything other than my site. This can not be changed. – Jonnymaboy Sep 01 '13 at 15:15

1 Answers1

1

Yes that would work:

<!--[if lte IE 6]>
  You're using IE 6!
<![endif]-->
<![if ! lte IE 6]>
  You're using something else!
<![endif]>

One thing to note is that older browser that do not support the conditional comments would see this as invalid HTML syntax. So another way to do it would be:

<!--[if lte IE 6]>
  You're using IE 6!
<![endif]-->
<!--[if !lte IE 6]>-->
  You're using something else!
<!--<![endif]-->

EDIT :

so wanted to say if less thean ie9 and not ie 6 then load from google cdn

<!--[if (lt IE 9)&(!IE 6)]>
Anything less than IE 9 except IE6
<![endif]-->

Use the AND operator.It Returns true if all subexpressions evaluate to true

meda
  • 45,103
  • 14
  • 92
  • 122
  • could i also use [if lt IE 9] and [! ie 6] for different scripts html5.js – Jonnymaboy Sep 01 '13 at 16:48
  • sorry my last question was not clear enough. Your first answer is perfect as it was. I just needed to do another sett of scripts for html5. so wanted to say if less thean ie9 and not ie 6 then load from google cdn. Thanks – Jonnymaboy Sep 01 '13 at 17:04