IE8浏览器模式与文档模式
有人可以简单地解释一下IE8浏览器模式和文档模式之间的区别吗?
- 是什么导致浏览器模式发生变化?
什么导致文档模式改变?
如果用户通过开发者工具更改模式,即使刷新页面,更改也会保留吗?
如果用户通过开发者工具更改模式,即使刷新页面,更改也会保留吗
我问这个问题是因为我们正在这里做一些 IE8 测试,不同的人有不同的模式组合,我想尝试弄清楚这是如何发生的。
Can someone please explain the difference between IE8 browser mode and document mode in simple terms?
- What causes the browser mode to change?
What causes the document mode to change?
If a user changes the mode(s) via developer tools, does the change remain even if the page is refreshed?
I am asking this because we are doing some IE8 testing here, and different people have different combinations of the modes, and i want to try to figure out how this is happening.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
摘自这篇文章 IE8 博客,标题为IE8 如何确定文档模式
因此,我们对您的问题得到以下答案:
问。 简单来说,浏览器模式和文档模式有什么区别?
A. 浏览器模式是在开发者工具中设置的,用于模拟不同 IE 浏览器版本的行为,而文档模式是在网页上定义的,用于告诉 IE 以不同的方式呈现网站,以实现兼容性目的。
问 是什么导致浏览器模式发生变化?
A. 用户在开发工具中更改浏览器模式。
问 什么原因导致文档模式发生变化?
A. Web 开发人员设置的 Doctype 和 X-UA-Compatible 元标记和标头。
问: 如果用户通过开发者工具更改模式,即使刷新页面,更改也会保留吗?
A. 浏览器模式将保留,但如果您更改 Doctype 和 X-UA-Compatible,它们将返回到页面上定义的内容。
更新: 正如 Adrien Be 在下面指出的那样,IE9+ 添加了通过刷新后保持不变的设置在开发工具中更改文档模式的功能。
From this article on the IE8 blog, entitled How IE8 Determines Document Mode
So from that we get the following answers to your questions:
Q. What is the difference between browser mode and document mode in simple terms?
A. Browser mode is set in the developer tools to emulate different IE browser version behaviors while document mode is defined on the web page to tell IE to render the site differently for compatibility purposes.
Q. What causes the browser mode to change?
A. The user changes the browser mode in the dev tools.
Q. What causes the document mode to change?
A. The Doctype and the X-UA-Compatible meta tag and header set by the web developer.
Q. If a user changes the mode(s) via developer tools, does the change remain even if the page is refreshed?
A. The Browser Mode will stay, but if you change the Doctype and X-UA-Compatible, they will go back to what is defined on the page.
UPDATE: As Adrien Be points out below, IE9+ adds the ability to change the document mode in the dev tools via a setting which will persist on refresh.
请在此页面中查看您的答案。
documentMode
属性返回浏览器用于呈现当前文档的模式。IE8 可以以不同的模式呈现页面,具体取决于
!DOCTYPE
或某些 HTML 元素的存在。该属性返回以下值之一:
注意: 如果未指定
!DOCTYPE
,IE8 将以 IE5 模式呈现页面!See your answer in this page.
The
documentMode
property returns the mode used by the browser to render the current document.IE8 can render a page in different modes, depending on the
!DOCTYPE
or the presence of certain HTML elements.This property returns one of following values:
Note: If no
!DOCTYPE
is specified, IE8 renders the page in IE5 mode!浏览器模式:指定浏览器发送到Web服务器的用户代理。如果您的 JavaScript 或后端代码根据用户代理字符串进行不同的呈现,则可能会出现呈现差异。例如,您可能会看到检查
navigator.userAgent
的 JavaScript。 (Mozilla/5.0(兼容;MSIE 8.0...)此值还用于处理 条件注释([if lte IE 9]、[if gt IE 8]等)。IE 11 中的模拟工具没有浏览器模式。它有用户代理下拉列表:指定用于处理标记的渲染引擎。这通常是我们看到渲染问题和浏览器不兼容的地方。最初的目标(无论好坏)是网站。 的模拟工具更加简单。
所有者可以通过元标记为其网站选择文档模式, 测试
如果您的目标是模拟旧版 IE8 浏览器,则应更改浏览器模式和文档模式。模拟并不完美,因此更彻底的选择是从 Microsoft 下载免费测试虚拟机 您可以在其中使用“真实”版本的 IE 8、9 等进行测试。
是什么导致这些值发生变化?
浏览器模式不会改变。(除非您在开发工具中进行更改。 )它是在向 Web 服务器发出请求之前设置的,
文档模式可以根据 Web 服务器响应进行更改。它可以通过 X-UA 兼容的 HTTP 响应标头、文档类型、元标记、Intranet 站点、标记进行更改。问题等
Browser Mode: Specifies the user agent sent by the browser to the Web Server. Rendering differences can occur if your JavaScript or back-end code renders differently based on the user agent string. For example, you may see JavaScript that checks
navigator.userAgent
. (Mozilla/5.0 (compatible; MSIE 8.0...) This value is also used to to process conditional comments ([if lte IE 9], [if gt IE 8], etc.). The Emulation tooling in IE 11 does not have a browser mode. It has a user agent drop-down instead.Document Mode: Specifies the rendering engine used to process the markup. This is typically where we see rendering issues and browser incompatibilities. The original goal (for better or worse) was website owners could choose a document mode for their site via a meta tag. In IE 11, the emulation tools are less confusing.
Testing:
If your goal is to emulate an old IE8 browser, you should change both browser mode and document mode. The emulation is not perfect, so a more thorough option is to download free test VMs from Microsoft where you can test with a *real" version of IE 8, 9, etc.
What causes these values to change?
The Browser mode will not change. (Unless you change it in Dev tools.) It is set before making the request to the web server.
The document mode can change based on web server response. It can be changed via a X-UA-Compatible HTTP response header, the doc type, meta tags, Intranet sites, markup issues, etc.
IE开发工具左上角有一个小按钮 ->显示“保留模拟设置”的模拟(选项卡)
请参阅此< /a> :
"设置持久化和重置
持久仿真设置图标已添加到仿真工具中。这将保留您当前的仿真设置,直到被明确禁用为止,从而允许您工作、关闭浏览器并以完整的仿真设置返回。右侧是“重置仿真设置”图标,可快速将工具重置回默认值。”
There is a little button in top left , in IE dev tools -> emulation (tab) that says "Persist emulation settings"
see this :
"Settings persistence and reset
A Persist Emulation settings icon is added to the Emulation tool. This will maintain your current emulation settings until specifically disabled, allowing you to work, close the browser, and come back with your emulation settings intact. To its right is a Reset Emulation settings icon, which quickly resets the tool back to default values."