What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

All overflow related websites ask "Are you sure you want to navigate away from this page" etc. etc. any time I try to leave a page after beginning a comment or answer - even if I have deleted ALL text in the input boxes after changing my mind. This is a small thing, but always bothers me. Should it be fixed?

share|improve this question
    
I curious, and have noticed this previously, too - why is that items that get marked "status-completed" don't also get closed ? –  warren Sep 26 '09 at 8:15

2 Answers 2

up vote 5 down vote accepted

It looks like SO attaches a listener for "beforeunload" event only after you start writing in a textarea. All that needs to be done here is check for a textarea value in that onbeforeunload event handler.

Right now:

window.onbeforeunload = function() {
  return 'You have started writing or editing a post.';
};

Could be easily changed to:

window.unbeforeunload = function() {
  // check other textareas too
  if ($('#wmd-input').val()) {
    return 'You have started writing or editing a post.';
  }
  return false;
}
share|improve this answer
    
I don't think this is right. When you return "false". The message that is returned will contain the text "false". I tried this using "return null", which seems to work in FF and Chrome, but not in IE. In IE the text "null" is returned. :) –  Trinorae Oct 17 '11 at 8:51

It's a browser thing. For example opera does not do this. Since it doesn't fire onunload() properly.

So it would require a check of the data within whatever box was filled (which can by many, since there are comment boxes also). Which might be the reason for this.

Could/should it be fixed? Sure.
Is there time? No clue.

share|improve this answer
3  
Opera is only different because it doesn't fire that event. It's not really a browser thing - all you'd have to do is add a check for the contents of the textarea. Which I would like. –  Tom Ritter Sep 15 '09 at 23:25
    
onunload() is a function fired by the browser. It's defined within the javascript handling of the browser. (Not StackOverflow). Hence it's a browser thing. –  Ólafur Waage Sep 16 '09 at 9:11
2  
I actually think it may be a browser thing. Since updating to Safari 4 i seem to be getting a lot more of those messages, so I think browsers may be adding this as a 'feature'. –  David Pearce Sep 16 '09 at 10:01
    
That's not a feature, that's a bug! –  random Sep 16 '09 at 12:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .