当浏览器的开发工具中的一个声明中暂停,如何在语句后立即终止执行? [英] When paused on a statement within the browser's dev tools, how to terminate execution immediately after that statement?

查看:214
本文介绍了当浏览器的开发工具中的一个声明中暂停,如何在语句后立即终止执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有这个功能:

Let's say I have this function:

function test () {

    // statements 1

    statement_X;

    // statements 2

}

我踩着槽与浏览器的开发工具的语句。现在,当我停在statement_X,我想终止函数执行(我不希望语句2将要执行的功能的一部分),犹如statement_X后面紧跟着一个收益; 语句

我知道,Chrome提供了内嵌的脚本编辑,因此暂停语句之后,我可以手动添加return语句,然后按CTRL + S重新执行了整个事情,但我需要这个功能的IE浏览器也一样,所以我希望有个通用的解决方案。

I know that Chrome has inline script editing, so I could manually add the return statement after the paused statement and then hit CTRL+S to re-execute the entire thing, but I need this feature for IE too, so I am hoping for a general solution.

终止执行初期似乎是一个很容易的事情(为浏览器),所以我期望从开发工具这样的功能。

Terminating execution early seems like an easy enough thing to do (for the browser), so I expect such a functionality from the dev tools.

推荐答案

我IE 9测试了这个成功的,所以我在这里张贴作为一个答案:而在 statement_X 脚本调试器,打F10让 statement_X 仍然执行,然后右键单击它的函数(用正确的花括号<行的最后一行code>} 终止函数体),并从下拉菜单中选择设置下一条语句。这将跳过执行,直到函数结束,如果有一个void return语句刚过 statement_X

I tested this successfully in IE 9, so I'm posting it here as an answer: while pausing at statement_X in the script debugger, hit F10 so statement_X is still executed, then right click on the last line of the enclosing function (the line with the right curly bracket } that terminates the function body), and select "Set next statement" from the drop down menu. This will skip execution until the end of the function as if there were a void return statement just after statement_X.

如果有一个函数的最后一行的任何其他语句,如下面的code,小心右键单击刚刚上花括号这种技术工作。

If there are any other statements on the last line of a function as shown in the code below, be careful to right click just on the curly bracket for this technique to work.

function test () { alert("statement 1");
    alert("statement 2"); } function test2 () { alert("statement 3"); }

这可能是有时在inline函数的情况下有必要,或缩小的脚本不打算进行调试。

This may be sometimes necessary in the case of inline functions, or in minified scripts not intended for debugging.

这篇关于当浏览器的开发工具中的一个声明中暂停,如何在语句后立即终止执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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