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;