阻止现代IE? [英] Blocking modern IE?

查看:99
本文介绍了阻止现代IE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阻止IE绝对不是最佳实践,但这是我对现有应用程序的要求.因为条件注释不可用,最有效的方法是什么在IE 10中?对于IE 9及更低版本,它将起作用:

Blocking IE is definitely not best practice, but it's something in my requirements for an existing application. What's the most effective way to do that since conditional comments aren't available in IE 10? For IE 9 and below this will work:

<!--[if IE]>
<script type="text/javascript">
window.location = "/IEblocked.html";
</script>
<![endif]-->

假设有一个最佳实践的JavaScript解决方案,我会找到什么陷阱?我想知道是否可能存在以下问题:

Assuming there's a best practice JavaScript solution, what gotchas might I find? I'm wondering if there might be issues around the following:

  • 事件触发顺序
  • iframe个超出我控制范围的元素
  • 在其他<script>标记的上下文中JS解决方案的优先级
  • 通过document.write('<script type="text/javascript" src="foo.js"></script>');方法加载的脚本.
  • Order of events firing
  • iframe elements that are beyond my control
  • Precedence of a JS solution in the context of other <script> tags
  • Scripts loaded via the document.write('<script type="text/javascript" src="foo.js"></script>'); method.

我感觉很多人可能会被迫喊出使用Modernizr" 你疯了,不要以这种方式将脚本放入DOM!" ,不幸的是,该应用程序很大,并且某些增强功能目前不在范围内.

I have a feeling a lot of folks might be compelled to shout out "use Modernizr" and "Are you crazy, don't put scripts in the DOM that way!", unfortunately the application is large and some enhancements are outside the scope at this point.

推荐答案

好吧,IE是唯一支持客户端VBScript的浏览器.

Well, IE is the only browser supporting client side VBScript.

因此,只需将其添加到您的页面中即可((当然,IEblocked.html本身除外)

So just add this to your pages: (except in IEblocked.html itself of course)

<script type="text/vbscript">
Document.Location = "IEblocked.html"
</script>

我知道它可以在IE9及以下版本中运行. 此评论足以证明它在IE10中仍然可以正常工作,并且对于将来的我碰到了Eric Lippert的这篇博客文章: VBScript的谣言死亡被严重夸大了,其中包含以下段落:

I know for a fact it's working in IE9 and below. This comment pretty much proves it's still working just fine in IE10 and as for the future I came across this blog post by Eric Lippert: Rumours of VBScript's Death Have Been Greatly Exaggerated which contains the following paragraph:

在可预见的将来,我们将继续支持VBScript和JScript .显然,VBScript,JScript,WSH等必须永远永远随操作系统一起提供,因为大量现有的业务关键代码都依赖于它们.把它描述为快死了"是过于戏剧化的.我们希望不受管理的COM脚本语言将继续有用很多年.目前,Visual Studio可持续工程团队负责VBScript,JScript,Windows脚本组件,Windows脚本宿主等.

We will continue to support VBScript and JScript for the foreseeable future. Obviously VBScript, JScript, WSH, etc, must continue to be shipped with the operating system forever, as huge amounts of existing business-critical code depends upon them. To characterize that as "dying a slow death" is excessively melodramatic. We expect that the unmanaged COM scripting languages will continue to be useful for many, many years. The Visual Studio Sustaining Engineering Team presently is responsible for VBScript, JScript, Windows Script Components, Windows Script Host, etc.

尽管已经发布了8多年,但我坚信我们在Windows核心中仍存在着很长的VBScript,并且将来的Internet Explorer版本将继续使用它.

Although posted over 8 years ago, I strongly belive we still have long years of VBScript existence in the core of Windows, and future versions of Internet Explorer will keep using it.

总而言之,我直接联系了Eric,并问"Internet Explorer版本将以多长时间支持VBScript作为客户端语言?".作为回应,他说:

To sum things up, I have contacted Eric directly and asked "How long will VBScript will be supported, as client side language, in Internet Explorer versions?". In response, he said:

仍然有许多公司客户依赖浏览器中的VBScript,因此MSFT放弃对此的支持是愚蠢的.支持成本非常低廉,即使是少数客户也失去了良好的信誉,这是很昂贵的.

There are still many corporate clients who depend on VBScript in the browser, so MSFT would be foolish to drop support for it. It is very cheap to support, and losing good will of even a small number of customers is expensive.

他不再在Microsoft工作,因此他的回答不是官方的,但这是我能获得的最接近的答案,不是多年的博客文章,而是直接从源头获得的.综合考虑所有因素,我可以得出结论,使用上述代码将在未来很多年内发挥作用. :)

He's no longer working in Microsoft so his answer is not official but it's the closest I can get and not years old blog post but directly from the source. All things considered, I can conclude that using the above code is going to work for many more years to come. :)

这篇关于阻止现代IE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆