如何在Google Chrome中调试时终止脚本执行? [英] How to terminate script execution when debugging in Google Chrome?

查看:1199
本文介绍了如何在Google Chrome中调试时终止脚本执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Google Chrome调试器中逐步浏览JavaScript代码时,如果我不想继续执行,如何终止脚本执行?我找到的唯一方法是关闭浏览器窗口。

When stepping through JavaScript code in Google Chrome debugger, how do I terminate script execution if I do not want to continue? The only way I found is closing the browser window.

按重新加载此页面将运行其余代码,甚至提交表单,就像按F8继续一样。

Pressing "Reload this page" runs the rest of the code and even submits forms as if pressing F8 "Continue".

更新

当脚本暂停时按F5(刷新) :

When pressing F5 (Refresh) while a script is paused:


  • Google Chrome(v22)运行脚本。如果脚本提交HTTP请求,则显示该请求的HTTP响应。原始页面不会刷新。

  • IE 9刚刚冻结。但是,IE有一个选项停止调试,按下(如果没有按F5键),继续在调试器外运行脚本。

  • Firebug的行为与Chrome相同。 li>
  • Google Chrome (v22) runs the script. If the script submits HTTP request, the HTTP response for that request is displayed. The original page is not refreshed.
  • IE 9 just freezes. However IE has an option "Stop Debugging" which, when pressed (provided you did not press F5 earlier), continues to run the script outside debugger.
  • Firebug behaves identically to Chrome.

关闭然后再次打开浏览器窗口并不总是下一个最简单的方法
,因为它会杀死浏览器会话状态,重要所有的断点也将丢失。

Closing and then opening again the browser window is not always the next easiest way because it will kill browser session state and that may be important. All your breakpoints are also lost.

更新(2014年1月)

UPDATE (Jan 2014):

在调试时刷新:


  • Chrome v31:让脚本运行并停止进一步的断点(但不提交ajax请求),然后刷新。

  • IE 11:刷新不起作用,但您可以按F5继续。

  • Firefox v26:让脚本运行,但不会停止进一步断点,提交ajax请求,然后刷新。

进度的种类

调试时导航到同一页面:

Navigate to the same page while debugging:


  • Chrome v31:与刷新相同。

  • IE 11:脚本被终止,新的浏览器会话开始(与关闭再次打开一样)。

  • Firefox v26:没有任何反应。

另外,juacala 建议有效的解决方法。例如,如果使用jQuery,一旦遇到任何jQuery方法,从控制台运行 delete $ 将停止执行。我已经在所有上述浏览器中测试过,并可以确认它正在运行。

Also juacala suggested an effective workaround. For example, if you are using jQuery, running delete $ from console will stop execution once any jQuery method is encountered. I have tested it in all above browsers and can confirm it is working.

更新(2015年3月)

最后,经过2年以上,接近10K的观点,正确的答案是由Alexander K.提供的。Chrome Chrome有自己的任务管理器,可以在没有关闭的情况下终止选项卡进程该选项卡本身,保留所有的断点和其他东西不变。

Finally, after over 2 years and almost 10K views, the right answer was given by Alexander K. Google Chrome has its own Task Manager which can kill a tab process without closing the tab itself, keeping all the breakpoints and other stuff intact.

我甚至去BrowserStack.com去测试它在Chrome v22,发现这是工作这个即使在那个时候也是这样。

I even went as far as BrowserStack.com to test it in Chrome v22 and found that this was working this way even at that time.

在IE或Firefox调试时,Juacala的解决方法仍然很有用。

Juacala's workaround is still useful when debugging in IE or Firefox.

推荐答案

在Chrome中,有任务管理器,可通过 Shift + ESC 或通过

In Chrome, there is "Task Manager", accessible via Shift+ESC or through


菜单→更多工具→任务管理器

Menu → More Tools → Task Manager

您可以选择页面任务,并按结束进程按钮结束。

You can select your page task and end it by pressing "End Process" button.

这篇关于如何在Google Chrome中调试时终止脚本执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆