Introduction to the use of CSS1compat in document. compatMode

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.