Here's a bookmarklet that will tell you whether or not the browser renders your page in Standards Complaiance Mode or Quirks Mode. The bookmarklet will figure this out for the page as well as for all the frames (and their frames) recursively. Enjoy!
这是一个书签,可以告诉您浏览器是否以“标准兼容模式”或“怪癖模式”呈现您的页面。 小书签将以递归方式在页面以及所有框架(及其框架)中解决该问题。 请享用!
安装 (Install)
Drag this to your bookmarklets/favorites or right click and add to favorites:
将此拖到您的书签/收藏夹中,或右键单击并添加到收藏夹:
样品输出(Sample output)
![quirks.png](https://img-blog.csdnimg.cn/img_convert/edba1c6ef9f335f175b709e395517ca3.png)
As you can see the page has two frames (probably iframes, doesn't matter), one of them is rendered in Standards Compliant Mode (CSS1Compat) the other one is in Quirks Mode (BackCompat). The overall document is CSS1Compat as well. For the frames, if they were named, you would see the name of the frame before the URL brackets.
如您所见,页面有两个框架(可能是iframe,这无关紧要),其中一个框架是在标准兼容模式(CSS1Compat)中呈现的,另一框架是在怪癖模式(BackCompat)中呈现的。 整个文档也是CSS1Compat。 对于框架,如果已命名,则将在URL括号之前看到框架的名称。
![quircks-gmail.png](https://img-blog.csdnimg.cn/img_convert/5218ec1bda0cd85722183d09a9f12a05.png)
代码 (The code)
The code is pretty simple, just accessing the compatMode of the the document object. Here it is in more human readable form (not one long line like bookmarket code).
该代码非常简单,只需访问document对象的compatMode即可。 在这里,它以更易读的形式出现(不是像书市代码那样的长行)。
var response = 'Document mode: ' + document.compatMode;
function checkFrames(w) {
if(w.frames && w.frames.length>0){
response+='\\n\\n';
for(var i=0;i<w.frames.length;i++){
var fr=w.frames[i];
try {
response+=fr.name +
' ('+fr.document.location+') - '+
fr.document.compatMode+'\\n';
} catch (e) {
response+='Could not access this frame\\n';
}
checkFrames(fr);
}
}
}
checkFrames(window);
alert(response);
Tell your friends about this post on Facebook and Twitter
在Facebook和Twitter上告诉您的朋友有关此帖子的信息
翻译自: https://www.phpied.com/quirks-bookmarklet/