Document. compatMode Introduction

Source: Internet
Author: User

The document. compatMode is very helpful for developing compatible web pages. We all know that the rendering of the box model by IE is very different in Standards Mode and Quirks Mode, the interpretation of the Box Model in Standards Mode is the same as that in other standard browsers, but there is a big difference in Quirks Mode, without declaring Doctype, by default, IE is in Quirks Mode. Therefore, for compatibility consideration, we may need to obtain the current document rendering method.
Document. compatMode comes in handy. It has two possible return values: BackCompat and CSS1Compat, which are explained as follows:
BackCompat Standards-compliant mode is not switched on. (Quirks Mode)
CSS1Compat Standards-compliant mode is switched on. (Standards Mode)
In the actual project, we also need to obtain whether the browser is IE, so that we can get the IE rendering mode. Code in Ext: isBorderBox = isIE &&! IsStrict.
When the document has a standard declaration, the value of document. compatMode is equal to "CSS1compat". Therefore, we can judge whether the document has a standard declaration based on the value of document. compatMode.
Var height = document. compatMode = "CSS1Compat "? Document.doc umentElement. clientHeight: document. body. clientHeight;

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.