开发者

Safari stuck in infinite loop whilst testing - any way out?

I'm hoping someone can help me out here - I'm testing some javascript and put an alert in a while loop to show how some variables were changing, but... I put it in 开发者_如何学Cthe wrong line and now Safari (on a Mac) is just looping the alert. Is there any way to stop it without force quitting the app (which I don't want to do as I've got other windows open).


I was able to close the tab by clicking "OK" on the alert (or pressing enter) and then immediately pressing Command-W. Note: It took several tries to get the timing just right.

Then, in my case, a confirmation alert popped up asking if I was sure I wanted to navigate away from the page. Then, the looping alert popped up on top. So, I positioned the looping alert on top of the confirmation alert so that the "OK" button of the looping alert was directly over the "OK" button of the confirmation alert. Then, I double-clicked (very fast) on the "OK" button (You might also try double-pressing enter.) to close both alerts.


Sorry, but no. The only way around this would be if you could close the particular tab in between alerts, but if they are popping up immediately after closing the box, then there's nothing you can do.


I just had this happen to me on Safari 5.1 in OS X Lion. After a lot of Googling I was unable to find the answer. I did some digging around and found the solution:

  1. Force Quit Safari
  2. Open the directory ~/Library/Safari/Extensions
  3. Delete your extension
  4. Open Safari

I know this question was asked a long time ago, but it is the first result on Google for "Safari extension stuck in infinite loop" so I figured it was worth the update.


BTW, FireFox would automatically prompt you about repeated popups, and you could just say "no". Why doesn't Safari do this?

I have tried numerous ways to stop this in Safari. The problem you discuss here is also a really stupid exploit by web pages, who use the pageUnload event to trap users with the dialog box.

You will have to force-quit. However, hold Shift down when you open Safari again to prevent loading the last pages. Or, repost/re-save your code so that when Safari loads the page, you don't have this problem in the first place.

In the future, don't use alart() to see this kind of information, just write it out to an empty div on your page.

In jQuery, do this in your looping code:

$('#testDiv').html('myVarA = ' + myVarA + ' myVarB = ' + myVarB + '<br>');  //write variables to test div.

or

 $('#testDiv').append('myVarA = ' + myVarA + ' myVarB = ' + myVarB + '<br>');  //append variables to test div, with a line break.

and add this to your page:

<div id="testDiv">Test Results Here</div>

By writing your variables out to a DIV, you can not only observe the variables, you will avoid the pop-up loop, and you will be able to interact with your dynamic page normally. Use "html" or "append" as needed.


I just had the same problem. I edited a file with an editor and connection to ftp. Then I opened a tab in safari and tested the file -> I was stuck in an infinite alert loop. So, what I did (this solution will of cause only work if the regarding file is online and not local)

  • Force quitting safari (safari settings must be put to remembering tabs)
  • Than turn off WLAN connection
  • Open browser, close the "infinite-loop causing" tab, and quit safari again
  • Turn on WLAN, open browser, fin.


Try this on Google Chrome. They have the same browser engine as Safari. If they had this problem, they must have solved it early on. Why isn't somebody at Apple not communicating with Google to fix this?

The request.servervariable you need to look at in both browsers is HTTP_USER_AGENT


To add to my previous comments here are the results of the request.servervariable variable HTTP_USER_AGENT:

Chrome:

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36

Safari:

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2

You may notice the difference in the AppleWebkit that is being used. Like I said, either Google had this problem and solved it or Apple let this bug creep in on a later version of it's browser. Need I say more?


HALELUYAH I FEEL LIKE AN IDIOT. This happened to me as well. Quick fix: right click the alert box, move it to the top right corner and align the (x) button with that of the browser window. double click. it'll pop up one more time but pres (x) again and it'll close safari. Worked on Windows.


I just got stuck in an infinite loop in Safari 8 (Yosemite). Killing Safari didn't help as the tab would reopen when Safari was launched again.

Closed Safari, deleted ~/Library/Safari/LastSession.plist and started Safari again. No previous tab reopen, problem solved!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜