Html 强制 IE 11 表现得像 IE 10

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18588769/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 12:58:56  来源:igfitidea点击:

Forcing IE 11 to behave as IE 10

htmlinternet-explorerinternet-explorer-11ie11-developer-tools

提问by jAsOn

We've run into an unusual bug with Internet Explorer and we need to force IE 11 to behave as IE 10 (since this bug is not present in IE 10).

我们在 Internet Explorer 中遇到了一个不寻常的错误,我们需要强制 IE 11 表现得像 IE 10(因为这个错误在 IE 10 中不存在)。

I have tried the following:

我尝试了以下方法:

    <meta http-equiv="x-ua-compatible" content="IE=10">

but unfortunately this does not work and I have not found anything relevant or helpful from Google searches or the docs. So how do we get IE 11to behave as IE 10?

但不幸的是,这不起作用,我没有从 Google 搜索或文档中找到任何相关或有用的信息。那么我们如何让 IE 11像 IE 10 一样运行呢?

回答by Marco Demaio

Do the following:

请执行下列操作:

  1. The correct meta string is: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10"/>(I added it just below the <title>.Preserve case, IE crappy code might be also case sensitive.)

  2. And a valid <!DOCTYPE...must be present at the very 1st line of your page (no space or linesbefore it)

  1. 正确的元字符串是: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10"/>我加它只是下面的<title>保留的情况下,IE蹩脚的代码可能也是区分大小写)。

  2. 并且有效的<!DOCTYPE...必须出现在页面的第一行(前面没有空格或行

You can verify if it works by hitting F12 to show the IE11 developer tools. On the left side there is a grey bar, scroll it down and select Emulation, if it shows Document mode: IE10it will be fine!

您可以通过按 F12 来显示 IE11 开发人员工具来验证它是否有效。在左侧有一个灰色条,向下滚动并选择 Emulation,如果它显示Document mode: IE10就可以了!

回答by Xm7X

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10">

Should work.

应该管用。

I know this will not set IE11 to IE10 mode but it might me worth a shot to try the edge setting.

我知道这不会将 IE11 设置为 IE10 模式,但我可能值得一试边缘设置。

<meta http-equiv="X-UA-Compatible" content="IE=edge">

This flow chart shows how the document mode works. The image is from the Microsoft MSDN site. http://msdn.microsoft.com/en-us/library/ff955275%28v=vs.85%29.aspx

此流程图显示了文档模式的工作原理。该图像来自 Microsoft MSDN 站点。http://msdn.microsoft.com/en-us/library/ff955275%28v=vs.85%29.aspx

Another useful link MSDN IE document modes http://msdn.microsoft.com/en-us/library/ff406036(v=vs.85).aspx

另一个有用的链接 MSDN IE 文档模式http://msdn.microsoft.com/en-us/library/ff406036(v=vs.85).aspx

enter image description here

在此处输入图片说明

回答by Helo

I just had the same problem. Its as if the x-ua-compatible tag does not change the document mode unless its the first meta tag in the header. I had a script tag above it.

我只是遇到了同样的问题。就好像 x-ua-compatible 标签不会改变文档模式,除非它是标题中的第一个元标签。我上面有一个脚本标签。

If you put the meta tag you tried as the first tag in the header and press F12, you will see the document mode stays on 10.

如果将您尝试的元标记作为标题中的第一个标记并按 F12,您将看到文档模式保持在 10。

回答by Hi10

This may help you to set response header with IIS: http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx

这可能会帮助您使用 IIS 设置响应标头:http: //msdn.microsoft.com/en-us/library/ff955275(v= vs.85).aspx

回答by Syed Mohamed

I also tried this, it doesn't works for me

我也试过这个,对我不起作用

<meta http-equiv="x-ua-compatible" content="IE=10">

also its works well if i manually change Useragentstring in F12 IE console to IE10,

I got a solution here below and its works for me, now my pages works properly in IE11 without changing anything in my code

如果我手动将 F12 IE 控制台中的 Useragentstring 更改为 IE10,它也能很好地工作,

我在下面找到了一个解决方案,它对我有用 ,现在我的页面在 IE11 中正常工作,而无需更改我的代码中的任何内容

Refer this https://stackoverflow.com/a/20422240/2089963

请参阅此 https://stackoverflow.com/a/20422240/2089963

回答by ahaliav fox

Setting in we.config:

在 we.config 中设置:

<system.webServer>
    <httpProtocol>
        <customHeaders>
            <clear/>

            <add name="X-UA-Compatible" value="IE=EmulateIE9"/>
        </customHeaders>
    </httpProtocol>