Introduction to the Css1compat use of Document.compatmode _javascript tips

Source: Internet
Author: User
Document.compatmode

Backcompat: Standard compatibility mode shutdown. Browser width: document.body.clientWidth;

Css1compat: Standard compatibility mode is open. Browser width: document.documentElement.clientWidth.
Copy Code code as follows:

var d = document,
DD = d.documentelement,
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:

The true width of the element = Margin-left + border-left-width + padding-left + width + padding-right + border-right-width + margin-right;

In quirks mode:

The width is the actual breadth of the element, the content width = width-(margin-left + margin-right + padding-left + padding-right + border-left-width + border-righ T-width)

In JS how to determine the current browser is how to resolve?
The Document object has a property compatmode, which has two values:

Backcompat corresponds to quirks mode
Css1compat corresponds to strict mode


Compatibility table for browsers

Http://www.quirksmode.org/compatibility.html

Historical reasons:

When the early browsers Netscape 4 and explorer 4 parsed the CSS and did not comply with the standards of the consortium, the parsing was called quirks mode, but as the standards of the consortium became more and more important, Many browsers begin to parse CSS according to the standard of the web, and follow the model of the standard for parsing CSS we call strict mode (strict mode)
Firefly

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.