Javascript 如何区分IE10的标准和quirks文档模式

Javascript 如何区分IE10的标准和quirks文档模式,javascript,jquery,internet-explorer,internet-explorer-10,Javascript,Jquery,Internet Explorer,Internet Explorer 10,我必须检查用户何时从IE10的开发者工具中选择了怪癖或标准文档模式。使用下面的代码,两种模式的值总是相同的,即10 document.documentMode 请让我知道如何区分IE10中的两种文档模式。我也在使用javascript。我使用了下面的代码,一切都很好。这适用于所有IE版本(已测试和验证:)) 你需要这个做什么?如果你的页面有一个有效的doctype,除非用户转到dev工具并手动更改它,否则它永远不会进入怪癖模式。坦白地说,如果他这样做了,他应该得到他应得的一切。只有IE10和@

我必须检查用户何时从IE10的开发者工具中选择了怪癖或标准文档模式。使用下面的代码,两种模式的值总是相同的,即10

document.documentMode

请让我知道如何区分IE10中的两种文档模式。我也在使用javascript。

我使用了下面的代码,一切都很好。这适用于所有IE版本(已测试和验证:))


你需要这个做什么?如果你的页面有一个有效的doctype,除非用户转到dev工具并手动更改它,否则它永远不会进入怪癖模式。坦白地说,如果他这样做了,他应该得到他应得的一切。只有IE10和@Spudley你是对的,这个问题才可能出现重复。在这个场景中,用户只是在更改文档模式,但我们的站点在标准模式下显示正确,但在怪癖模式下显示扭曲。为此,我们计划显示一条错误消息。由于“document.documentMode”为两种模式提供了相同的值,即10,因此我无法区分它们。任何关于这方面的建议都将不胜感激。
//Checks the document mode of the IE and displays an error if the doc mode is not supported
function CheckDocMode() {

//Get the browser name
var browserName = navigator.appName;

//Do not display the Div containing the error message
document.getElementById('DocModeError').style.display = 'none';

//Check if the browser is IE
if (browserName == "Microsoft Internet Explorer") {

    //Get the IE version, document mode and complatibility mode
    var IEVersion = GetIEVersion();
    var IEDocMode = document.documentMode;
    var IECompatibilityMode = document.compatMode;

    //Confirm that the browser is IE8/9/10
    if (IEDocMode != undefined) {

        //Do not display the error message if the IE=10 and Doc Mode = Standard
        if ((IEVersion == 10 || IEVersion == 9 || IEVersion == 8 || IEVersion == 7)
            && (IEDocMode == 10 && IECompatibilityMode == "CSS1Compat")) {
            return;
        }

        //Display the error if the document mode is anything other than IE8 and IE9
        if (IEDocMode != 8 && IEDocMode != 9) {
            document.getElementById('DocModeError').style.display = 'block';
        }
    }
}
}

function GetIEVersion() {
    var myNav = navigator.userAgent.toLowerCase();
    return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
}