Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

javascript - Cancel infinite loop execution in jsfiddle

When you get an infinite loop in jsfiddle in Chrome, your only choice (that I know of) is to close the tab. Of course, this means you lose all your work in the current window! Is there an easy way to stop an infinitely executing script?

  1. I have the developer tools open because I was doing some debugging.
  2. I am able to pause the script and step through the loop.
  3. I can't find anywhere to stop the script.
  4. I can't modify the script or variables to stop the infinite loop (because the script execution occurs in an iframe on a separate domain, so modifying data in the iframe with JavaScript is not allowed and generates an Exception in the console).

It all started because I decided to swap directions on my loop from

for (var c = 0; c <= 11; c++)

to

for (var c = 12; c > 0; c++)

But as you can see above, I forgot to change it from c++ to c--.

Any ideas?? I still have the tab open and I'm hoping to get it back without closing the tab :-)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

How to do it without Developer Mode:

  • Open a new tab
  • Open the Task Manager with Shift-Escape
  • Kill task
  • Use back button for the killed tab (JSFiddle won't run the script)
  • Fix bug
  • Update

Or on MacOS,

  • Open Activity Monitor
  • Kill the first "Google Chrome Helper (Renderer)" process. It's probably JSFiddle
  • Fix the issue
  • Run the code

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...