Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

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
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. :) – StefK 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
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
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'. – Josh Hunt 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 .