<meta http-equiv="X-UA-Compatible" content="IE=edge"> 是什么作用?

1725

如果一个网页以<!DOCTYPE html>开头和不加的区别是什么?

<!DOCTYPE html> 
<html> 
  <head> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 

如果页面以...开头

<!DOCTYPE html> 
<html> 
  <head> 
     <!-- without X-UA-Compatible meta -->
如果没有区别的话,我想我可以忽略 X-UA-Compatible 元标头,因为我希望在所有 IE 版本中以最标准的模式呈现。
12个回答

3

2.1.3.5 X-UA-Compatibility元标记和HTTP响应头

在任何版本的Microsoft Edge中都不会实现此功能。

<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" />

请查看https://msdn.microsoft.com/zh-cn/library/ff955275(v=vs.85).aspx了解更多信息。

是的,我知道我来晚了,但我刚刚遇到了一些问题和讨论,并且最终我的老板让我从我正在处理的所有文档中删除X-UA-Compatible标签。

如果此信息已过时或不再相关,请纠正我。


3

这个问题只需要谷歌一下就可以找到答案,不过我还是解释一下:

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

Understanding legacy document modes

Use the following value to display the webpage in edge mode, which is the highest standards mode supported by Internet Explorer, from Internet Explorer 6 through IE11.

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

Note that this is functionally equivalent to using the HTML5 doctype. It places Internet Explorer into the highest supported document mode. Edge most is most useful for regularly maintained websites that are routinely tested for interoperability between multiple browsers, including Internet Explorer.

Note Starting with IE11, edge mode is considered the preferred document mode. (In earlier versions, it was considered experimental.) To learn more, see Document modes are deprecated. Starting with Windows Internet Explorer 8, some web developers used the edge mode meta element to hide the Compatibility View button on the address bar. As of IE11, this is no longer necessary as the button has been removed from the address bar. Because it forces all pages to be opened in standards mode, regardless of the version of Internet Explorer, you might be tempted to use edge mode for all pages viewed with Internet Explorer. Don't do this, as the X-UA-Compatible header is only supported starting with Internet Explorer 8.

Tip If you want all supported versions of Internet Explorer to open your pages in standards mode, use the HTML5 document type declaration, as shown in the earlier example.

在搜索结果中还包括:


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接