javascript - 仅在 IE7 中禁用 JavaScript

标签 javascript jquery browser internet-explorer-7

我遇到了一个场景,我需要在除 IE7 之外的所有浏览器中加载 JavaScript。任何帮助是极大的赞赏。我已经尝试过以下代码:

<!--[if gt IE 7]>
<script type="text/javascript">
    //Some script XXX to execute
</script>
<![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<script type="text/javascript">    
    //Some script XXX to execute
</script>
<!--<![endif]-->

最佳答案

我认为这也有效

<!--[if !(IE 7)]>
   // tag here
<![endif]-->

您还可以组合使用

<![if !IE]>
   // script tag
<![endif]>

<!--[if (gte IE 8)&(lt IE 7)]>
   // script tag
<![endif]-->

请参阅此处的文档 http://msdn.microsoft.com/en-us/library/ms537512%28v=vs.85%29.aspx

我不确定您是要加载整个文件还是只是几行脚本。如果只有几行,jquery 方式会更容易

关于javascript - 仅在 IE7 中禁用 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17682973/

相关文章:

javascript - localStorage - clear() 或 removeItem()?

javascript - 我正在尝试使用 JavaScript 来验证电话号码

javascript - 将日期值(存储在变量中)分配给日期选择器

jquery - Bootstrap wysiwyg 无法在 IE 中添加超链接

javascript - 如何在某个div上应用动画?

java - Eclipse Internet Explorer 浏览器出现问题(帮助系统及其他)

javascript - Vue.js 将组件数据值传递给子组件

javascript - 使用 jQuery 突出显示表格中的列

image - 为什么可以显示带有 "image/jpeg"数据 URL 的 Base64 编码 PNG?

testing - TestCafe 是否有设置默认浏览器窗口大小的方法?