3 ms·
This can be a little dicey when AJAX was used to render the form that you're thinking about submitting; for a browser to Do It Right they may need to cache comp
by drostie 10y ago
This can be a little dicey when AJAX was used to render the form that you're thinking about submitting; for a browser to Do It Right they may need to cache complicated stuff like (a) the entire DOM and (b) the entire state of the JS interpreter at the moment navigation began away from the page. Even if we only do this on backwards navigation and immediately trash it when we navigate forwards to a new location, it still sounds to a developer's ear like a memory leak waiting to happen. It might be mitigated if you store no more than, say, 10 pages back.
- iopq 10y agowhen you get the form back up, the browser should fill it because it should remember the form state from earlier alternatively, just don't browse away when you have something filled in a form - just ask the user if they meant to do that
- shkkmo 10y agoDetecting and/or saving "something filled in a form" is hard to do with 100% accuracy across all the oddly implemented forms out there. While I feel it has slowly gotten better over the years, especially on well implemented pages, it is still a common enough issue that another solution was needed. I do wish they had mad a user configurable flag rather than forcing people to use plugins to re-acquire functionality they had before.
- makapuf 10y agoOr maybe like just disable it if there is something to lose ie there is a form and I entered something in it with the keyboard
- Jtsummers 10y agoThat would be worse. Then the expected behavior (that backspace would navigate back) wouldn't occur because I'm filling in this form. Even though I've left the field (so backspace is captured by the tab and not the form field) and have decided to abandon the comment and go back to reading the thread.
- iopq 10y agoyou can just say "Cancel" or "Navigate away" in the dialog that comes up if you have written a long paragraph it shouldn't just be lost because you accidentally pressed a key on your keyboard
- onion2k 10y agoI'm not sure why it'd be hard. "If there's a dom element that's an input of any time, and the user has focused it at any point, ask for confirmation on page exit" would work fine. The only case where I can see it being an issue would be a site that uses a select element as a menu, but I've not seen any do that in years.
- PunchTornado 10y agoI think it can easily get abused, just some hidden focused inputs
- onion2k 10y agoBrowsers already have a pageUnload event that can block a user leaving until they confirm they want to. This would effectively be the same.