Document. compatMode
BackCompat: Disabled in standard compatibility mode. Browser width: document. body. clientWidth;
CSS1Compat: enabled in standard compatibility mode. Browser width: document.doc umentElement. clientWidth.
Copy codeThe Code is as follows:
Var d = document,
Dd = d.doc umentElement,
Db = d. body,
Dc = d. compatMode = 'css1compat ',
Dx = dc? Dd: db;
CWidth = dx. clientWidth;
CHeight = dx. clientHeight;
SWidth = dx. scrollWidth;
SHeight = dx. scrollHeight;
SLeft = dx. scrollLeft;
STop = dx. scrollTop;
In Standars mode:
True width of the element = margin-left + border-left-width + padding-left + width + padding-right + border-right-width + margin-right;
In Quirks mode:
Width indicates the actual width of the element, content width = width-(margin-left + margin-right + padding-left + padding-right + border-left-width + border-right-width)
In js, how does one determine the method in which the browser is parsing?
The document object has a property compatMode, which has two values:
BackCompat corresponds to quirks mode
CSS1Compat corresponds to strict mode
Browser compatibility
Http://www.quirksmode.org/compatibility.html
Historical Reasons:
When the early browsers Netscape 4 and Explorer 4 parse css but do not comply with W3C standards, the parsing method is called quirks mode (weird mode ), however, as W3C standards become more and more important, many browsers began to parse CSS in accordance with W3C standards. The strict mode is used to parse CSS in the same way as W3C standards)
Firefly