开发者

How do I abort script execution in firebug?

If I'm getting an infinite loop and find the error stepping throug开发者_StackOverflow中文版h the code, how do I then stop it so that I can reload the page with fixed code?


A. For recursive infinite loops:

There should always be some variable name that contains the function that is being called recursively, regardless of whether the function is private or global.

To stop the recursion, run a code snippet in the console that sets the variable containing the function to an empty function. So if your code is like this:

function doLoop() {
    function privateFunction() {
        privateFunction();
    }
    privateFunction();
}

Then your code snippet would be this:

privateFunction = function(){}

B. For for, and while loops:

Write a line that sets the exit condition to true. In this case, your code to put in the console could be "i = 6":

var n = 5
for (var i = 0; i < n; ){
    var x = 1;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜