javascript 为什么 Google Chrome 的脚本调试器不能让我设置断点?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4359101/
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
Why won't Google Chrome's script debugger let me set a breakpoint?
提问by Kev
I'm running Google Chrome 8.0.552.215 on Windows 7 x64 Ultimate. I have a simple jQuery inline script much like any I've successfully debugged in the past:
我在 Windows 7 x64 Ultimate 上运行 Google Chrome 8.0.552.215。我有一个简单的 jQuery 内联脚本,就像我过去成功调试过的任何脚本一样:
<script type="text/javascript">
$(document).ready(function () {
// do stuff here
// but reduced to a simple
alert('here!');
});
</script>
I'm browsing to the secure (https) section of the site I'm working on.
我正在浏览我正在处理的网站的安全 (https) 部分。
There are no script errors, the scripts all run just fine, but I can't set a breakpoint.
没有脚本错误,脚本都运行得很好,但我无法设置断点。
I tried debugging this in Firefox's Firebug and and can set and hit breakpoints just fine.
我尝试在 Firefox 的 Firebug 中调试它,并且可以很好地设置和命中断点。
Why would this happen?
为什么会发生这种情况?
采纳答案by Patrick Lewis
This bug was fixed yesterday (February 3) with the introduction of a new api for managing JavaScript breakpoints: http://code.google.com/p/chromium/issues/detail?id=69988
此错误已于昨天(2 月 3 日)修复,引入了用于管理 JavaScript 断点的新 API:http: //code.google.com/p/chromium/issues/detail?id= 69988
I downloaded the most recent Chromium nightly from http://build.chromium.org/f/chromium/snapshots/and was able to successfully set breakpoints in JavaScript, which I had been unable to do using the current stable/beta/dev builds of Chrome.
我每晚从http://build.chromium.org/f/chromium/snapshots/下载了最新的 Chromium,并且能够在 JavaScript 中成功设置断点,而使用当前的 stable/beta/dev 版本我无法做到这一点铬。
Hopefully this fix will be incorporated into the next releases of Chrome. Until then, adding debugger; statements to your code is a decent workaround for setting breakpoints.
希望此修复程序将合并到下一个版本的 Chrome 中。在此之前,添加调试器;代码中的语句是设置断点的一个不错的解决方法。
回答by Jan
Does this happen when you refresh the page when the developer tools are already open? It happened to me too in that case.
在开发者工具已经打开的情况下刷新页面会发生这种情况吗?在这种情况下,它也发生在我身上。
Workaround:
解决方法:
Set resource tracking to always enabled.
Close the developer tools.
Refresh the page.
Open the developer tools, tab resources.
Set your breakpoint.
File a bugreport herebecause it is not normal behavior.
Post a link to this bugreport back on SO so we can all star it.

