javascript 使用 Internet Explorer 兼容模式的缺点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6125040/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cons of using Internet Explorer's Compatibility Mode
提问by Michal Bernhard
What are cons of force a web site viewed in IE to compatible mode? Say we force IE9 to IE8 compatiblity mode?
将在 IE 中查看的网站强制为兼容模式的缺点是什么?说我们强制 IE9 到IE8 兼容模式?
- Performance drawbacks
- Can't use any new IE9 specific features like HTML5/CSS3/SVG
- 性能缺陷
- 不能使用任何新的 IE9 特定功能,如 HTML5/CSS3/SVG
Why?
为什么?
We run legacy web app which is developed since 2000 so it's a mess ball fighting to be compatible with Chrome, Opera, Firefox, IE6/7/8 and now we decide to add IE9 to the list. But with IE9 we run in issues with printing, "Permission deniend" JavaScript errors (probably something about cross-frame JavaScript calls) and next issues - the easy workaround is to force IE9 to behave as a IE8 and then everything works fine. But I am still not sure if it's way to go...
我们运行自 2000 年以来开发的旧版 Web 应用程序,因此与 Chrome、Opera、Firefox、IE6/7/8 兼容是一团糟,现在我们决定将 IE9 添加到列表中。但是对于 IE9,我们遇到了打印问题、“拒绝权限”JavaScript 错误(可能与跨框架 JavaScript 调用有关)和下一个问题 - 简单的解决方法是强制 IE9 表现得像 IE8,然后一切正常。但我仍然不确定它是否可行......
回答by Raynos
first our app is public site (for our clients)
首先我们的应用程序是公共站点(对于我们的客户)
You have a public website developed in 2000 and it doesn't work on modern browsers? Deprecate it or re-write it.
你有一个 2000 年开发的公共网站,但它在现代浏览器上不起作用?弃用它或重新编写它。
Don't hack your code to support modern browsers, the website is clearly poorly written and doesn't apply to standards. You can't get away with this.
不要为了支持现代浏览器而修改你的代码,该网站显然写得不好,不符合标准。你不能逃避这个。
The only place where you can get away with this level of incompatibility is intranet applications and even then you should simply state "it works on browser X, live with it"
唯一可以避免这种级别不兼容性的地方是 Intranet 应用程序,即便如此,您也应该简单地声明“它适用于浏览器 X,并与之共存”
You can't say that to public facing clients.I mean you can try, but have fun losing business to your competitors.
你不能对面向公众的客户说这些。我的意思是您可以尝试,但要享受将业务输给竞争对手的乐趣。
Re-develop your website to match the W3C HTML/CSS standards and the ES5 standardsand it will be completely future facing (for some years).
重新开发您的网站以匹配 W3C HTML/CSS 标准和 ES5 标准,它将完全面向未来(几年)。
Alas, the way the web works is that anything more then 5 years old is deprecated.So either re-write it every 5 years or get out of the web business.
唉,网络的工作方式是任何超过5 年的东西都被弃用了。所以要么每 5 年重写一次,要么退出网络业务。
In terms of actually using compatibility mode, don't. IE6-8 are horrible engines and should be avoided like the plague. If you use them then you can't write future facing standards compliant code.
在实际使用兼容模式方面,不要。IE6-8 是可怕的引擎,应该像瘟疫一样避免。如果您使用它们,那么您将无法编写面向未来的符合标准的代码。
Your code needs to match the standardsand you should fix / shim / patch any browser specific bugs where those browsers don't implement the standards.
您的代码需要符合标准,并且您应该修复/填充/修补浏览器未实现标准的任何浏览器特定错误。
回答by ??????
You cannot say you have tested in IE6/7/8/9 until you have tested in those different versions. Emulating the test environment is not the same as using the test environment. To my knowledge IE7/8 compatibility modes are the older render engines, not the underlying browser as a whole, bugs and all. It is closed source so you will never know.
你不能说你已经在 IE6/7/8/9 中测试过,除非你在那些不同的版本中测试过。模拟测试环境与使用测试环境不同。据我所知,IE7/8 兼容模式是较旧的渲染引擎,而不是整个底层浏览器、错误等等。它是闭源的,所以你永远不会知道。
Convert Microsoft's free to download virtual disk images for cross-browser testing to Virtualbox images and put them on a machine that just runs Virtualbox. An old machine will do, run the VMs headless and access them with remote desktop. In that way you will be able to test in all browsers without burdening your machine with MS/Spyware.
将微软免费下载的用于跨浏览器测试的虚拟磁盘映像转换为Virtualbox 映像,并将它们放在仅运行Virtualbox 的机器上。一台旧机器可以,无头运行虚拟机并使用远程桌面访问它们。通过这种方式,您将能够在所有浏览器中进行测试,而不会让 MS/Spyware 给您的机器带来负担。
回答by ShaneBlake
I believe your system admins can set IE to compatibility mode for all intranet traffic using the Group Policy Editor. Any site you create will from this point forward, you can add a meta tag to force IE9 to render natively and use all the newer features...
我相信您的系统管理员可以使用组策略编辑器将 IE 设置为所有 Intranet 流量的兼容模式。从现在开始,您创建的任何站点都可以,您可以添加元标记以强制 IE9 本地呈现并使用所有较新的功能...
I'm having to do that on my current project using the following doctype and meta tag in my header:
我必须在我的标题中使用以下文档类型和元标记在我当前的项目中执行此操作:
<!DOCTYPE HTML >
<meta http-equiv="X-UA-Compatible" content="IE=100" />
回答by Schroedingers Cat
Compatability mode is something that MS introduced to give people some chance to upgrade their applications, not for long term use. AFAIU.
兼容模式是微软引入的,目的是让人们有机会升级他们的应用程序,而不是长期使用。阿法乌。
If you want your application to be compatible with IE9, then you will have to change it. If you are trying to maintain IE6-9 compatibility then you have a real challenge, and you should consider whether this is really practical - in essence, you need at least 2 distinct sets of html. Is this practical for you?
如果您希望您的应用程序与 IE9 兼容,那么您将不得不对其进行更改。如果您正在尝试保持 IE6-9 兼容性,那么您将面临真正的挑战,您应该考虑这是否真的实用 - 本质上,您至少需要 2 组不同的 html。这对你来说实用吗?
IE9 compatibility mode is different form IE9 and IE8 - it draws bits from both. So you need to do a full test agaisnt the compatibility mode version, and ensure that it remains working against this.
IE9 兼容模式与 IE9 和 IE8 不同 - 它从两者中汲取了一些知识。因此,您需要针对兼容模式版本进行全面测试,并确保它仍然可以解决此问题。
So in answer to the question, the cons are that you are not being IE9 compatible, and there is a danger that when IE10 comes out, your code will not run against that in any mode. You are putting the effort into compatibilty testing without providing for future changes. You would do better, in the longer term, to make your code IE9 compatible. Also, the message you are giving your clients is that your code base is not going to be compatible for much longer. Unless you are talking to them about a re-work, this is a real negative.
因此,在回答这个问题时,缺点是您不兼容 IE9,并且存在一种危险,即当 IE10 出现时,您的代码将无法在任何模式下运行。您正在努力进行兼容性测试,而无需为未来的更改做准备。从长远来看,您会做得更好,使您的代码与 IE9 兼容。此外,您向客户传达的信息是,您的代码库将不会兼容太久。除非你和他们谈论返工,否则这是一个真正的负面影响。
However, it sounds like your entire code needs a re-work, to forget about IE6 and be written for modern working browsers. Using compatibility mode until that happens is probably OK. If you do this - and tell your clients - then staying in compatibility mode is viable.
然而,听起来您的整个代码需要重新工作,忘记 IE6 并为现代工作浏览器编写。使用兼容模式直到发生这种情况可能没问题。如果你这样做——并告诉你的客户——那么保持兼容模式是可行的。
回答by isNaN1247
Using compatibility mode will NOT cause the browser to use the JavaScript engine that was present in the old version of IE.
使用兼容模式不会导致浏览器使用旧版本 IE 中存在的 JavaScript 引擎。
By that I mean it will run any JavaScript code using the IE9 engine. Which was a problem for us when debugging an old product that had a problem with IE7/8.
我的意思是它将使用 IE9 引擎运行任何 JavaScript 代码。在调试有 IE7/8 问题的旧产品时,这对我们来说是一个问题。