[英]Chrome Developer Tools pauses the initialization of jQuery 1.7
Chrome的开发者工具是我喜欢使用的一套优秀的工具。 不幸的是,当我刷新页面同时保持开发人员工具窗口打开时,我遇到了一个非常奇怪的问题:Chrome暂停javascript执行并指向下面指定的行。
try {
// This should fail with an exception
// Gecko does not error, returns false instead
matches.call(document.documentElement, "[test!='']:sizzle"); // this is where it breaks
} catch (pseudoError) {
pseudoWorks = true;
}
尽管异常本身位于try-catch块中,但异常会导致脚本暂停。 有什么方法可以改变这种行为吗? 还是有什么我错过了?
我刚刚解决了这个问题(在我的情况下,可能会有所不同)。 我不小心点击了chrome控制台中的“Pause on Exceptions”按钮。 这一个: https : //developers.google.com/chrome-developer-tools/docs/scripts-breakpoints#js_exceptions
这是一个小的,容易错过的Pause on Exceptions按钮的位置,以及它的三个切换状态:
如果有人搜索
div.querySelectorAll("*,:x");
应该重定向到这里。
可能这是一个已知的bug,请查看: http : //bugs.jquery.com/ticket/7535 。 我在那里找到了这个解决方案,我希望它有所帮助:
try {
// This should fail with an exception
// Gecko does not error, returns false instead
// <orig. $jquery-1.5:>
// matches.call( document.documentElement, "[test!='']:sizzle" );
// <proposal to Ticket #7535, 2011-03-24:>
if( ! html.mozMatchesSelector || document.currentScript ){
matches.call( html, "[test!='']:sizzle" );
}
//else{
// /*FF lt 4*/
//}
} catch( pseudoError ) {
pseudoWorks = true;
}
// <testing only>
// alert('MalformedSelectorException thrown: ' + pseudoWorks );
如果您使用的是Chrome,请执行以下操作:
单击检查器(cog)中的“设置”图标。 一般来说,有一个名为“管理框架黑盒子......”的按钮。
您可以使用它来忽略在调试器中评估某些脚本。 这是一个捕捉jQuery东西的简单正则表达式。 /jquery(.*)\\.js$
发现这个问题寻找与Safari相关的问题,所以我猜答案可能有用:
在Safari Web Inspector中,可以通过转到Breakpoints选项卡(ctrl-7)来实现。 取消选择“所有例外”并选择“所有未捕获的例外”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.