0x800a139e - JavaScript运行时错误:SyntaxError

CRA*_*OLO 10 jquery windows-8 visual-studio-2012

我是Visual Studio Express 2012 for Windows 8的新手.

我已经能够得到一个简单的应用程序工作得很好,但它会抛出相同的"例外".

所以为了测试,我刚刚开始了一个全新的空白JavaScript项目,只是在default.html中链接了jQuery代码,并运行了调试器,但仍然抛出以下异常:

Exception was thrown at line 1217, column 4 in ms-appx://xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/Scripts/jquery-2.1.1.js
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 1235, column 4 in ms-appx://xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/Scripts/jquery-2.1.1.js
0x800a139e - JavaScript runtime error: SyntaxError
Run Code Online (Sandbox Code Playgroud)

如何编辑jQuery代码或我需要做些什么来摆脱抛出此异常?

jQuery代码中抛出第一个异常的部分:

assert(function (div) {
    // Support: Windows 8 Native Apps
    // The type and name attributes are restricted during .innerHTML assignment
    var input = doc.createElement("input");
    input.setAttribute("type", "hidden");
    div.appendChild(input).setAttribute("name", "D");

    // Support: IE8
    // Enforce case-sensitivity of name attribute
    if (div.querySelectorAll("[name=d]").length) {
        rbuggyQSA.push("name" + whitespace + "*[*^$|!~]?=");
    }

    // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
    // IE8 throws error here and will not see later tests
    if (!div.querySelectorAll(":enabled").length) {
        rbuggyQSA.push(":enabled", ":disabled");
    }

    // Opera 10-11 does not throw on post-comma invalid pseudos
    div.querySelectorAll("*,:x"); // *********** THIS IS LINE 1217 ***********
    rbuggyQSA.push(",.*:");
});
Run Code Online (Sandbox Code Playgroud)

jQuery代码中抛出第二个异常的部分:

if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
    docElem.webkitMatchesSelector ||
    docElem.mozMatchesSelector ||
    docElem.oMatchesSelector ||
    docElem.msMatchesSelector) )) ) {

    assert(function( div ) {
        // Check to see if it's possible to do matchesSelector
        // on a disconnected node (IE 9)
        support.disconnectedMatch = matches.call( div, "div" );

        // This should fail with an exception
        // Gecko does not error, returns false instead
        matches.call( div, "[s!='']:x" ); // ***** THIS IS LINE 1235 *****
        rbuggyMatches.push( "!=", pseudos );
    });
}
Run Code Online (Sandbox Code Playgroud)

TooLongDon'tRead - 我尝试过的事情:

从我的理解,它假设抛出异常,但微软不会批准一个抛出任何错误/异常的应用程序...我很困惑,没有一个明确的答案(这很容易发现),因为它可能是一个问题,每个人都使用jquery与visual studio.我甚至尝试使用jquery2.02,人们说没有抛出这些例外,但它仍然适用于我.我自己尝试编辑jquery代码,但这导致了很多其他错误.

我还尝试了nuget中的windows 8的jquery(2年内没有更新)...我想这是想解决这个问题,但它实际上给了我更多的运行时错误.

Nza*_*all 9

我在使用IE11时遇到了与jQuery类似的问题.事实证明,即使JQuery 2.1.1声称与IE11兼容,我发现在某些情况下它不是并且返回错误.尝试使用最新的JQuery 1.X版本.它具有与2.1.1完全相同的功能,但仍然具有在2.1.1中删除的IE 7,8和9的兼容性检查.

  • 根据我的最后评论 - 没关系.当Visual Studio配置为中断所有JavaScript错误时,可能会发生此问题.这个错误是预期的,由jQuery处理,但Visual Studio不知道.似乎如果我忽略错误并继续进行,一切都很好...... (4认同)
  • @ManojNayak - 要停止因任何特定类型的错误而中断,请查看 Visual Studio 中的异常设置。这可以通过打开“异常设置”窗口来查看。请参阅 Visual Studio 菜单项“调试”,然后是子菜单“Windows”,然后是子菜单“异常设置”或按快捷键 Ctrl+Alt+E。您可能想要使用名为“JavaScript 运行时异常”的异常设置来获得您想要的结果...... (2认同)

Pau*_*tte 4

如果该window对象可用,请定义一个window.onerror函数来捕获所有未捕获的异常:

 window.onerror = function (message, url, lineNo)
  {
  console.log('Error: ' + message + '\n' + 'Line Number: ' + lineNo);

  return true;
  }

console.log(window);
console.log(1=2);
Run Code Online (Sandbox Code Playgroud)

参考