For document. compatMode, many of my friends may have little contact with me, but they do not know how to use it. 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;
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.