How to select Document Mode in Firefox and Chrome without setting a DOCTYPE?

时光毁灭记忆、已成空白 提交于 2019-12-10 17:32:45

问题


I am working on converting a web page that was creating using old web standards to support modern web browsers. The web page currently renders in Quirks Mode within Internet Explorer 9, Firefox, and Chrome.

In IE9, I am able to select the "Document Mode" in which I would like the web page I am viewing to render in. This makes things easier, as I can jump between Quirks Mode and IE9 Standards Mode. I do not have to add/modify the DOCTYPE tag within the code of the web page.

Can I do the same in Firefox and Chrome?


回答1:


No. In most browser–except IE–there are three different modes:

Quirks mode

This is where browsers wilfully do not follow certain standards in order to be compatible with broken content. IE < 10 is frozen in IE5.5 era quirks mode. Other browser’s quirks mode, including IE10 have evolved to be interoperable with each other, so they break in more predictable ways.

The usual method of setting quirks mode is not not include a doctype, or include content before the doctype.

It is highly recommended not to rely on quirks mode rendering.

Almost standards mode

This renders like standards mode, except the behaviour of vertical sizing of table cells.

Triggered with a doctype of:

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

Standards mode

This is the mode developers should be using, with browsers behaving to the defined standards. Triggered by using a valid doctype such as <!DOCTYPE html>

There is no way to set any other modes in Non-IE browsers. You can find out more at http://hsivonen.iki.fi/doctype/

I’d advise just to try to update the site to standards mode if you can, as it will only cause more issues the longer it is left in legacy rendering modes. It will also not take advantage of enhancements in modern versions of IE, such as performance improvements.



来源:https://stackoverflow.com/questions/14858977/how-to-select-document-mode-in-firefox-and-chrome-without-setting-a-doctype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!