Home > Web Front-end > JS Tutorial > body text

document.compatMode introduction_javascript skills

WBOY
Release: 2016-05-16 18:52:44
Original
943 people have browsed it

Today I saw the use of document.compatMode in ext. I feel that this is still very helpful for us to develop compatible web pages. We all know that there is a big difference between IE's rendering of the box model in Standards Mode and Quirks Mode. The interpretation of the box model in Standards Mode is the same as that of other standard browsers, but it is very different in Quirks Mode. When Doctype is not declared, IE defaults to Quirks Mode. So for compatibility reasons, 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 get whether the browser is IE, so that we can get the rendering mode of IE. Code in Ext: isBorderBox=isIE&&!isStrict.
When a 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.documentElement.clientHeight : document.body.clientHeight;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template