0x800a139e – JavaScript运行时错误:SyntaxError

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

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

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

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 

如何编辑jQuery代码或我需要做什么来摆脱抛出的这个exception?

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

 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(",.*:"); }); 

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

 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 ); }); } 

TooLongDon’tRead – 我尝试过的事情:

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

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

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

如果window对象可用,请定义window.onerror函数以捕获所有未捕获的exception:

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

参考

  • 使用window.onerror更好地处理错误

  • W3C Wiki:window.onerror

当我将网页从VS10移动到VS12时,我遇到了同样的错误。 我认为这个问题在某种程度上与转移有关。 我阅读了上述问题和答案,并得出结论,我的错误是使用Windows 8.1和IE 11进行测试。我使用FireFox浏览器测试了我的VS12版本软件,错误已经消失。 我不知道如何在IE 11中更改jQuery来构建1.x. 如果我这样做,我会因为我希望我的软件使用最流行的浏览器进行操作。

谢谢你的帮助。