简体   繁体   English

如何仅针对 Internet Explorer 7 以编程方式关闭 JavaScript?

[英]How to switch off JavaScript programmatically only for Internet Explorer 7?

I want to turn off JavaScript using JavaScript (and/or jQuery) code, only if the page is viewed in IE7.我想使用 JavaScript(和/或 jQuery)代码关闭 JavaScript,只有在 IE7 中查看该页面时。

How can this be done?如何才能做到这一点?

Would be grateful for the magic code snippet!将不胜感激神奇的代码片段!

Use conditional comments.使用条件注释。

http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx

<![if !(IE 7)]>
    // Script tags here
<![endif]>

You can check if ($.browser.msie && $.browser.version < 8) and not run your code.您可以检查if ($.browser.msie && $.browser.version < 8)并且不运行您的代码。

You can´t turn JavaScript off.您不能关闭 JavaScript。 You can however exclude IE7 by using Downlevel-revealed Conditional Comments .但是,您可以使用Downlevel-revealed Conditional Comments排除 IE7。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过JavaScript在Internet Explorer 11中仅收集数组中的唯一值? - How to collect only unique values in an Array in Internet Explorer 11 by JavaScript? 如何仅使用JavaScript定位Internet Explorer 11? - How can I target only Internet Explorer 11 with JavaScript? Javascript 仅有时执行(Internet Explorer 7 和 8) - Javascript executing only sometimes (Internet Explorer 7 and 8) 外部Java脚本仅在Internet Explorer上未定义 - External Javascript Undefined only on Internet Explorer Internet Explorer(仅限)Javascript Head createStyleSheet错误 - Internet Explorer (only) Javascript Head createStyleSheet Error Internet Explorer仅部分加载JavaScript / CSS - Internet Explorer only part loading JavaScript/CSS 在某些情况下,例如特定于Internet Explorer的CSS或特定于Internet Explorer的JavaScript代码,如何仅将Internet Explorer 10定位? - How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code? 如何以编程方式允许 Internet Explorer 使用 javascript 并在没有用户确认的情况下播放视频? - How to programmatically allow Internet Explorer to use javascript and to play videos without user confirmation? 如何解决开/关JavaScript - how to solve on/off switch javascript 在Internet Explorer &lt;= 8中以编程方式调用时,javascript onclick事件不会冒泡 - javascript onclick event not bubbling up when called programmatically in internet explorer <= 8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM