【问题标题】:if ie6 do this else do that. How can i do this如果 ie6 执行此操作,则执行此操作。我怎样才能做到这一点
【发布时间】:2013-09-04 17:53:45
【问题描述】:

我需要检查 ie 6 是否在本地加载所有 js 文件,或者其他更高或不同的文件,即 chrome 等,然后从 cdn(google 或任何其他)加载

我已经在为样式使用条件 cmets

<!--[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,所有这些用户都在同一个位置,需要从站点而不是 cdn 加载 js 文件。因此,如果 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]>

谢谢

【问题讨论】:

  • 我认为&lt;!--[if gt IE 6]&gt;&lt;!--&gt;Something else&lt;!--&lt;![endif]--&gt; 会起作用。我不确定! lte IE 6 语法是否正确。这个wiki link 中有一些示例。最后,我完全同意以下评论和 duffymo 的回答。
  • 请用户现代化
  • 我确实有 。但老实说,我什至没有检查过它的来源或作用。同样,如果它是一个 CDN,那么它不会为这些特定的 ie6 用户工作。 ie6 用户有防火墙阻止访问我的站点以外的所有内容。这是无法更改的。

标签: javascript asp.net css coding-style


【解决方案1】:

是的,这会起作用:

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

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

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

编辑:

所以想说如果少于 ie9 而不是 ie 6 然后从谷歌加载 cdn

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

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

【讨论】:

  • 我会试试这个。谢谢
  • 我也可以使用 [if lt IE 9] 和 [!即 6] 用于不同的脚本 html5.js
  • 对不起,我的最后一个问题不够清楚。你的第一个答案是完美的。我只需要为 html5 做另一组脚本。所以想说如果少于 ie9 而不是 ie 6 然后从 google cdn 加载。谢谢
  • 好的我明白了,我修好了
猜你喜欢
  • 1970-01-01
  • 2013-01-19
  • 2021-10-27
  • 2016-05-17
  • 2023-03-09
  • 2021-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多