问题描述
我知道,现代的浏览器一般有两种渲染模式:标准模式和怪异模式。浏览器检测到标题的DOCTYPE。
I know that modern browsers generally have two render mode: standard mode and quirk mode. The browser detects the heading DocType.
的问题是如何以检测呈现当前页面的模式在运行时。是否有任何工具的Firebug做到这一点?
The question is how to detect render mode of current page at runtime. Is there any Firebug tool to do that?
推荐答案
IE8之前:
alert('Page was rendered in ' +
((document.compatMode == 'CSS1Compat') ? 'Standards' : 'Quirks') + ' Mode.');
有关IE8:
var vMode = document.documentMode;
var rMode = 'IE5 Quirks Mode';
if(vMode == 8){
rMode = 'IE8 Standards Mode';
} else if(vMode == 7){
rMode = 'IE7 Strict Mode';
}
alert('Rendering in: ' + rMode);
请注意,默认的标准模式获得的IE8的新的典型应用该类超支行为,你需要在IE8标准模式进行渲染。
Be aware that to gain the benifits of IE8's new "standards mode by default" behavior you'll need to be rendering in IE8 Standards Mode.
此模式会影响你的HTML + CSS的的渲染,以及修补程序为JavaScript 的方法,如的document.getElementById(ID);
和 .setAttribute(名称,值);
This mode affects the rendering of your HTML+CSS as well as the fixes to JavaScript methods like document.getElementById( id );
and .setAttribute( name, value );
这篇关于如何检测浏览器的渲染模式为当前页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!