我是
Windows 8的Visual Studio Express 2012的新手.
我已经能够得到一个简单的应用程序工作正常,但它会抛出相同的“异常”.
所以要测试,我刚刚开始一个全新的空白JavaScript项目,并将jQuery代码链接到default.html中,并运行调试器,并且还会抛出以下异常:
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代码或者我需要做什么来摆脱抛出的这个异常?
抛出第一个异常的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(",.*:");
});
抛出第二个异常的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 – 我试过的事情:
从我的理解,假设抛出异常,但微软不会批准一个正在抛出任何错误/异常的应用程序…我很困惑,没有一个明确的答案(这很容易发现),因为每个人都可能会遇到一个使用视觉工作室的jquery的问题.我甚至尝试使用jquery2.02哪些人说没有抛出这些例外,但它仍然为我做.我尝试自己编辑jquery代码,但是这引起了很多其他错误.
我也尝试过nuget中的Windows 8的jquery(在2年内还没有更新)…我猜想是要解决这个问题,但实际上给了我更多的运行时错误.
解决方法
当我使用IE11时,我遇到了一个类似的问题.事实证明,即使JQuery 2.1.1声称是IE11兼容,我发现在某些情况下,它不是并返回错误.尝试使用最新的JQuery 1.X构建.它具有与2.1.1完全相同的功能,但仍然具有在2.1.1中删除的IE 7,8和9的兼容性检查.