javascript 以编程方式修复 IE 中的浏览器模式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15636939/
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
Fixing the Browser Mode in IE Programmatically
提问by Alaa
I have a website that works in full compatibility on All browsers including IE 7 to 9
我有一个完全兼容所有浏览器的网站,包括 IE 7 到 9
I was shocked when i tried it on IE-10, Too many bugs, and because I have no time to fix this for IE-10 and i am also using third party controls "Telerik", I decided to try a simple solution by turning the Document and the browser mode back to ie9.
我在 IE-10 上尝试时感到震惊,错误太多,因为我没有时间为 IE-10 修复这个问题,而且我也在使用第三方控件“Telerik”,我决定尝试一个简单的解决方案Document 和浏览器模式回到 ie9。
In Developer Tools for IE-10, If i set Manually The Document Mode to IE9 Standards and the Browser Mode to IE9, All the bugs will fly away, I have found a way that forcing the IE-10 to use the Document Mode :
在 IE-10 的开发者工具中,如果我手动将文档模式设置为 IE9 标准,将浏览器模式设置为 IE9,所有错误都会消失,我找到了一种强制 IE-10 使用文档模式的方法:
<meta http-equiv="X-UA-Compatible" content="IE=9" />
But what about the Browser Mode? is there any way to set its value before rendering?
但是浏览器模式呢?有没有办法在渲染前设置它的值?
Solution : The way i used in this question was correct, however the solution for me was updating the windows in the hosting server, There was many updates, suspected one is: Update for Internet Explorer 8 Compatibility View List for Windows Server 2008 R2 x64 Edition (KB2598845)
解决方案:我在这个问题中使用的方法是正确的,但是我的解决方案是更新托管服务器中的窗口,有很多更新,怀疑是:更新 Internet Explorer 8 Compatibility View List for Windows Server 2008 R2 x64 Edition (KB2598845)
采纳答案by Spudley
You've already got the document modesorted. Does that not solve the problem? It usually does the trick.
您已经对文档模式进行了排序。这不解决问题吗?它通常可以解决问题。
The browser modeshouldn't need to come into play, as it doesn't affect the rendering at all; it just changes the UA string, so it shouldn't have any impact on the page layout.... unless there is something in the code that tries to do a browser-specific hack by looking at the UA string.
该浏览器模式不应该需要发挥作用,因为它没有影响到所有的渲染; 它只是改变了 UA 字符串,所以它不应该对页面布局产生任何影响......除非代码中有一些东西试图通过查看 UA 字符串来执行特定于浏览器的黑客攻击。
If you have got something in your code that does that, then that's where the problem is and you should probably fix it. (using the UA string to affect page layout is generally frowned on as a bad practice anyway; there are usually better ways to do it)
如果您的代码中有这样的东西,那么这就是问题所在,您可能应该修复它。(无论如何,使用 UA 字符串来影响页面布局通常被认为是一种不好的做法;通常有更好的方法来做到这一点)
If it's Telerik itself that's doing it, then I would imagine they'd have already been forced to find a fix for it (IE10 has been out for a while and they'd have had other users complaining), so you may find that updating to the latest version will solve the problem.
如果是 Telerik 本身在做这件事,那么我想他们已经被迫为它找到修复程序(IE10 已经推出一段时间了,他们会有其他用户抱怨),所以你可能会发现更新到最新版本将解决问题。