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

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

问题描述

假设我有这个功能:

  function test(){

//语句1

statement_X;

//语句2

}

我正在用浏览器的开发工具踩下语句。现在,当我暂停在statement_X时,我想终止函数执行(我不希望执行函数的statement 2部分),就好像statement_X紧随其后一个返回; 语句。



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



早期终止执行似乎是一件容易的事情(对于浏览器),所以我期望这些开发工具的功能。



解决方案

我在IE 9中成功测试了这个,所以我在这里作为答案发布:在$ code> statement_X 在脚本调试器中,点击F10,所以 statement_X 仍然执行,然后右键单击封闭函数的最后一行(具有正确卷曲的行括号} 终止函数体),并从下拉菜单中选择设置下一个语句。这将跳过执行,直到函数结束,就好像在 statement_X 之后有一个void return语句。





如果最后还有其他语句一行功能如下面的代码所示,请小心右键单击大括号,以使此技术正常工作。

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

在内联函数的情况下,有时候可能需要这样做, 。


Let's say I have this function:

function test () {

    // statements 1

    statement_X;

    // statements 2

}

I'm stepping trough the statements with the browser's dev tools. Now, when I'm paused at "statement_X", I would like to terminate the function execution (I don't want the "statements 2" part of the function to be executed), as if the "statement_X" is immediately followed by a return; statement.

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.

解决方案

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.

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"); }

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

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

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