3

I'm trying to learn the source of this warning:

enter image description here

Is this done under control of the browser, or is this part of the code implemented by the website - Stack Exchange in this case? If it's "Stack Exchange", please read on; otherwise pls let me know & I'll delete the question.

This warning/dialog "pops up" when triggered by what the browser thinks is an accidental "unload" of form data. I think I'm happy to have such a warning, as it seems a reasonable "fail safe" device.

But I have one freaking HUGE problem with it: The default action is Leave Page. And with the twitchy Mac keyboard (where turning your head and coughing are keyboard "shortcuts"), the Leave Page option is executed, and I just lost an hour's work in a text box. :(

If the default option could be changed to Stay on Page, this might actually be useful.

1
  • 1
    Along these lines are laptop touchpads that are factored calibrated to respond to a pixie's sigh in the next room.
    – goldilocks Mod
    Sep 14 '20 at 14:12
3

That's a browser-based function, and all Stack Exchange could do is change the text of the prompt. See e.g. this link. They're not doing this, which can be observed by comparing the dialog in Safari:

enter image description here

with the one from Firefox:

enter image description here

and the one from Chrome:

enter image description here

But note that Stack Exchange does have a feature which helps here: it automatically saves drafts of any question or answer you write. Just return to the page and you can continue writing your post. Since drafts are stored server-side (they're tied to your account) you can even start in one browser (e.g. on a mobile device) and finish on another one (e.g. on your laptop).

5
  • I see the save draft feature in use frequently. Mostly, "it just works". But sometimes it doesn't - like today. I had a partial answer I had saved and published. Today, I began a major edit on that published answer... ~2 hours work. Then, out of nowhere, comes the dialog (shown above), then something that my Macbook interprets as input, and POOF - 2 hours work is gone bye-bye with no known method of recovery. So yeah - the save draft feature works - some of the time.
    – Seamus
    Sep 14 '20 at 6:12
  • Wrt this being a browser-based function, I found some info that said it was a function supported by Mozilla, but the developer (SE folks) had to invoke it. That said, I did a search in a SE page here & got no matches for beforeunload. I figured it might be "hidden" in a library (?). Are you certain this isn't done by SE?
    – Seamus
    Sep 14 '20 at 6:17
  • Mozilla support said this re who controls presentation of the pop-up: Websites can set up an event listener on the "beforeunload" event. Firefox displays that standard dialog in that case. Firefox won't display the dialog on its own. Consequently, I feel that part of your answer is misleading. If you'd like to edit your answer, I'll consider accepting, but I can't do that as it is now written. And by all means - if you disagree, please forward something supporting your statement.
    – Seamus
    Sep 14 '20 at 21:44
  • It's probably activated in the onchange event of the form elements. I can't tell since the JavaScript is minified, but window.onbeforeunload is null when loading the edit page and not null after doing some editing. Stack Exchange developers will need to tell how it works exactly.
    – Glorfindel
    Sep 15 '20 at 19:15
  • FWIW: My solution to this (the occasional failure of SE's autosave feature) are the Firefox extensions named Form History Control II, and Textarea Cache.
    – Seamus
    Jan 13 at 1:22

You must log in to answer this question.

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