Safari remains "load" when window.onbeforeunload returns false

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

The problem is this ( happens with Safari 5.1.3 and not the latest version of Chrome ):

  • Visit this page: http://www.4guysfromrolla.com/demos/OnBeforeUnloadDemo1.htm
  • Click on one of the links, you will receive a warning about whether you really want to leave this page.
  • Click "Stay on Page"
  • Reload the page using cmd-R. You will be offered a different time if you really want to leave the page.
  • Click "Stay on the page."
  • Safari remains in a β€œload” state, and a progress bar indicates that it should load the next page.

Is this a bug from Safari? Is there a way around this problem?

+5
source share
2 answers

I was able to reproduce this problem even if I skipped steps OP 2 and 3. In any form of reboot this problem appears. Minimalistic steps to reproduce:

  • Visit the page in question .
  • The hit will reboot.
  • Click the "Stay on the page" button.

(-, " ", ;)

  • " ", X, - 10%.
  • "" (, , script).
  • "" - , .

Webkit/Safari UI - . Webkit , Safari, , Safari .

+1

, - > https://developer.mozilla.org/en/DOM/window.onbeforeunload

. . :

window.onbeforeunload = function (e) {
  e = e || window.event;

  // For IE and Firefox prior to version 4
  if (e) {
    e.returnValue = 'Any string';
  }

  // For Safari
  return 'Any string';
};
0

All Articles