jQuery 0x800a139e - JavaScript 运行时错误:SyntaxError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24131986/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
0x800a139e - JavaScript runtime error: SyntaxError
提问by CRABOLO
I'm new to Visual Studio Express 2012 for Windows 8.
我是 Visual Studio Express 2012 for Windows 8 的新手。
I have been able to get a simple app to work just fine, but it would throw the same "exceptions".
我已经能够让一个简单的应用程序正常工作,但它会抛出相同的“异常”。
So to test, I just started a brand new blank JavaScript project, and just linked the jQuery code in default.html, and ran the debugger, and the following exceptions are still thrown :
所以为了测试,我刚刚启动了一个全新的空白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
How can I edit the jQuery code or what do I need to do to get rid of this exception being thrown?
如何编辑 jQuery 代码或者我需要做什么才能摆脱抛出的这个异常?
The part of the jQuery code where the first exception is being thrown :
引发第一个异常的 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(",.*:");
});
The part of the jQuery code where the second exception is being thrown :
引发第二个异常的 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 );
});
}
TooLongDon'tRead - Things I've tried :
TooLongDon'tRead - 我尝试过的事情:
From what I understand, it's suppose to throw the exception, however microsoft won't approve an app that is throwing any errors/exceptions... I'm quite confused that there isn't a clear cut answer to this (that is easily found), since it is likely an issue everyone has that uses jquery with visual studio. I even tried using jquery2.02 which people said didn't throw these exceptions , but it still did for me. I tried editing the jquery code myself, but that caused a whole lot of other errors.
据我所知,它应该抛出异常,但是微软不会批准抛出任何错误/异常的应用程序......我很困惑对此没有明确的答案(这很容易找到),因为这可能是每个人在 Visual Studio 中使用 jquery 时都会遇到的问题。我什至尝试使用 jquery2.02,人们说它没有抛出这些异常,但它仍然对我有用。我尝试自己编辑 jquery 代码,但这导致了很多其他错误。
I also tried the jquery for windows 8 in nuget (that hasn't been updated in like 2 years)... that I guess was suppose to resolve this stuff, but it actually gave me even more runtime errors.
我还在 nuget 中尝试了适用于 Windows 8 的 jquery(大约 2 年没有更新)......我想应该可以解决这些问题,但它实际上给了我更多的运行时错误。
回答by Nzall
I encountered a similar issue with jQuery when using IE11. It turns out that even though JQuery 2.1.1 claims to be IE11 compatible, I found that in some situations it's not and returns errors. Try using the most recent JQuery 1.X build. it has the exact same functionality as 2.1.1, but still has the compatibility checks for IE 7, 8 and 9 that were removed in 2.1.1.
我在使用 IE11 时遇到了类似的 jQuery 问题。事实证明,即使 JQuery 2.1.1 声称与 IE11 兼容,我发现在某些情况下它不是并返回错误。尝试使用最新的 JQuery 1.X 版本。它具有与 2.1.1 完全相同的功能,但仍然具有在 2.1.1 中删除的 IE 7、8 和 9 兼容性检查。
回答by Paul Sweatte
If the window
object is available, define a window.onerror
function to catch all uncaught exceptions:
如果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);
References
参考
回答by Tom Rowlett
I had the same error when I moved my web page from VS10 to VS12. I thought the problem was somehow having to do with the transfer. I read the above questions and answers and concluded that my error was testing using Windows 8.1 and IE 11. I tested my VS12 version software using the FireFox browser and the error has gone. I don't know how to change the jQuery in IE 11 to build 1.x. If I did I would because I want my software to operate using the most popular browsers.
当我将网页从 VS10 移动到 VS12 时,我遇到了同样的错误。我认为问题在某种程度上与转移有关。我阅读了上述问题和答案并得出结论,我的错误是使用 Windows 8.1 和 IE 11 进行测试。我使用 FireFox 浏览器测试了我的 VS12 版本软件,错误消失了。我不知道如何更改 IE 11 中的 jQuery 以构建 1.x。如果我这样做了,我会这样做,因为我希望我的软件能够使用最流行的浏览器运行。
Thank you for all your help.
谢谢你的帮助。