如果ie6做到这一点那么做。我怎样才能做到这一点

时间:2013-09-01 14:28:53

标签: javascript asp.net css coding-style

我需要检查是否ie 6如果是这样在本地加载所有js文件或者其他任何更高或差异,即chrome等然后加载从cdn(谷歌,或任何其他)

我已经在使用条件评论

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

但我知道我们有很多用户使用ie6,所有这些用户都在同一个位置,需要从网站加载js文件而不是cdn&#39; s。因此,如果ie6从本地站点加载js文件,则从cdn加载任何其他内容。

我该怎么做?

以下是否有效:

类似于:(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]>

由于

1 个答案:

答案 0 :(得分:1)

是的,这样可行:

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

需要注意的一点是,不支持条件注释的旧浏览器会将此视为无效的HTML语法。所以另一种方法是:

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

编辑:

  

所以想说,如果少了iean ie9而不是6则从谷歌加载   CDN

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

使用AND运算符。如果所有子表达式都计算为true,则返回true