Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safari stays "loading" when window.onbeforeunload returns false

The following gist: https://gist.github.com/1876791 (borrowed from the demo in this question) is a dead simple example of usage of window.onbeforeunload in js.

The problem we have is the following (Happens with Safari 5.1.3 and not Latest Chrome version):

  1. Visit this page: https://web.archive.org/web/20211028110528/http://www.4guysfromrolla.com/demos/OnBeforeUnloadDemo1.htm
  2. Click on one of the links, you will get an alert asking you if you really want to leave this page
  3. Click "Stay On Page"
  4. Reload the page using cmd-R. You will be asked another time if you really want to leave the page
  5. Click "Stay On Page".
  6. Safari stays in a "loading" status, with the progress bar showing as if it were to load the next page.

Is this a bug from Safari ? Is there a way to circumvent this problem ?

like image 918
rpechayr Avatar asked Nov 14 '22 09:11

rpechayr


1 Answers

I was able to reproduce this issue even while skipping OP's steps 2 and 3. Any form of reload exhibits this issue. Minimalistic steps to reproduce:

  1. Visit the page in question.
  2. Hit reload.
  3. Click "Stay on Page" button.

The loading progress is visually pre-engaged right after the reload hit and stays so for the entire life of the confirm dialog (apparently in an effort to communicate the "hanging over cliff edge"-type mature of the situation ;) However:

  • When dialog is dismissed with "Stay on page" button, it leaves the stopping X symbol on and the loading progress still engaged and frozen somewhere around 10% mark.
  • This "loading" can NOT be cancelled by any means (keyboard, button, script).
  • Network tab in Web Inspector asserts NO loading happening.

This really looks like a Webkit/Safari UI bug - it looks to fail to disengage the progress bar in stay-on-page conditions. Best would be to report it to the Webkit team or, since you experience this in Safari, maybe the Safari team would be better.

like image 52
Petr Vostrel Avatar answered Nov 16 '22 04:11

Petr Vostrel