简体   繁体   English

IE9:如何强制2个页面显示相同,为什么? 第一个是Quirks模式,另一个是IE7兼容

[英]IE9: how to forces 2 pages to display the same why? The first is in Quirks mode, the other IE7 Compatible

No matter what I try to do, pages keep looking significantly different depending on whether they are from my local machine or the development server. 无论我尝试做什么,页面的外观都会保持明显不同,具体取决于它们是来自本地计算机还是来自开发服务器。 When pressing F12, I've finaly noticed that pages have different instructions on the top: 当按F12键时,我最终注意到页面的顶部有不同的说明:

1) Pages displayed by my local machine have the following values: 1)我的本地计算机显示的页面具有以下值:

Browser Mode: IE9 Compatible View 浏览器模式: IE9兼容视图

Document Mode: Quirks 文件模式:怪癖

HTML starts with this line of code HTML以这一行代码开头

<html xmlns="http://www.w3.org/1999/xhtml">

2) Whereas pages displayed by the development server have the following values: 2)开发服务器显示的页面具有以下值:

Browser Mode: IE9 Compatible View 浏览器模式: IE9兼容视图

Document Mode: IE7 Standards 文件模式: IE7标准

HTML starts with this line of code HTML以这一行代码开头

<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" -->

 <html xmlns="http://www.w3.org/1999/xhtml">

It looks like the the first line of the instruction that's making those pages to display differently. 看起来该指令的第一行使这些页面以不同的方式显示。

Do I need to add that line to pages coming from my local machines as well? 我是否还需要将该行添加到本地计算机的页面上? Why and how to do that? 为什么以及如何做到这一点?

Thanks for helping 感谢您的帮助

Without a doctype, you are in quirks mode, and, no matter what else you do, pages won't look the same as in strict mode. 没有doctype,您将处于怪异模式,并且,无论您做什么,页面在严格模式下都不会看起来一样。

New web pages should always have a doctype and always use strict. 新网页应始终具有doctype,并始终使用strict。 Rarely would a newly created page have a need for quirks or the transitional doctype you are using. 新创建的页面很少需要您使用的怪癖或过渡文档类型。

Add either that transitional doctype on your first line or, preferably, the strict version: 在第一行中添加该过渡文档类型,或者最好在严格版本中添加:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

Better yet, use the new type: <!DOCTYPE html> which will keep all browsers in strict mode, including IE back to IE6 (or even IE4? Don't recall). 更好的是,使用新的类型: <!DOCTYPE html> ,它将使所有浏览器都处于严格模式,包括从IE回到IE6(甚至是IE4?不要回想)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM