【问题标题】:Running jQuery crashing on IE10/Win7在 IE10/Win7 上运行 jQuery 崩溃
【发布时间】:2013-02-15 05:00:59
【问题描述】:

我目前只是在我的 ASP.net 网页(实际上是 Site.Master 文件)中包含 jQuery(1.9.1,但旧 1.8.3 的行为方式相同)。在 IE9/Win7-64 下运行一切正常,但自从我升级到 IE10(仍然是 Win7-64)后,现在当我在本地运行网页,选择 Internet Explorer 并从 Visual Studio 中运行时,我遇到了异常。

jquery-1.9.1.js 文件的第 4224 行出现异常。

// Opera 10-12/IE8 - ^= $= *= and empty values
// Should not select anything
div.innerHTML = "<input type='hidden' i=''/>";
if ( div.querySelectorAll("[i^='']").length ) {
    rbuggyQSA.push( "[*^$]=" + 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");
rbuggyQSA.push(",.*:");

jQuery,无论是旧的还是新的,似乎都不能正确处理 Windows 7 上的 IE10。我在 Opera 10-11 崩溃了,这很有趣。

我还看到 4242 发生崩溃

if ( (support.matchesSelector = isNative( (matches = docElem.matchesSelector ||
    docElem.mozMatchesSelector ||
    docElem.webkitMatchesSelector ||
    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" );
        rbuggyMatches.push( "!=", pseudos );
    });

这是错误之一:

Exception was thrown at line 4224, column 4 in http://localhost:49928/jquery/jquery-1.9.1.js
0x800a139e - JavaScript runtime error: SyntaxError
Source line: div.querySelectorAll("*,:x");

有人有什么想法吗?

【问题讨论】:

  • 有什么例外?您发布的代码中的第 4224 行是哪一行?
  • 我将对话框中的异常复制到我的问题中,见上文。
  • 根据 jQuery 团队的说法,这很好,因为它是预期的。他们在更高级别捕获异常并自行处理。蹩脚,但情况就是这样

标签: jquery asp.net windows-7 visual-studio-2012 internet-explorer-10


【解决方案1】:

jQuery 团队在某些情况下使用异常来实现逻辑流。 请参阅我针对与 WinJS 应用程序相同的问题提交的此错误:http://bugs.jquery.com/ticket/14123

由于异常已处理,他们不认为这是一个问题。我愿意,因为如果没有设置“break on throw”,它会使调试应用程序变得更加困难。

所以,这就是问题所在。你对此无能为力。

【讨论】:

  • 感谢您的新评论。很遗憾,但调试我的 .Net Web 应用程序要困难得多。
  • 你去吧,几年后我遇到了同样的问题,我已经尝试了你所说的一切,仍然没有改变。该怎么办?请帮忙!
【解决方案2】:

除了消息之外,还有什么问题吗?正如评论所说,“这应该失败并出现异常。”该异常由assert() 方法处理,不应导致程序终止。 Visual Studio 中应该有一个选项,只显示未处理的异常。

更多信息:This page 描述了如何在 Visual Studio 中找到“JavaScript 首次机会例外”设置,将其关闭应该会消除您所看到的内容。请注意,如果您正在调试 Promise,您可能不想将其关闭,链接中的文章进一步讨论了它。但我相信 jQuery 在这种情况下会正确处理异常,如果您不在调试器中运行,您将看不到该消息。

【讨论】:

    【解决方案3】:

    我在 Windows 7 上的 Safari 中遇到了同样的问题,当时我将调试器设置为在未捕获的错误上中断。问题似乎是调试器期望 catch(e) 发生在同一个函数中。如果您继续逐个执行语句,catch(e) 稍后会在 assert() 函数中很好地发现错误:

    function assert( fn ) {
        var div = document.createElement("div");
    
        try {
            return fn( div );
        } catch (e) {
            return false;
        } finally {
            // release memory in IE
            div = null;
        }
    }
    

    令人沮丧,嗯!?

    【讨论】:

      猜你喜欢
      • 2011-05-04
      • 2012-03-29
      • 2012-06-09
      • 2012-08-15
      • 1970-01-01
      • 2020-03-16
      • 2013-01-20
      • 2011-03-21
      • 1970-01-01
      相关资源
      最近更新 更多