I\'m building a fail safe for my form that is going to warn users that if they leave the page their form data will be lost (similar to what gmail does).
window.
Move any script to a click
event handler instead, with a fallback page for users without JavaScript:
click
The unobtrusive JS champions out there will probably object to the use of the onclick
attribute, but the fact is that it works, it's the simplest way to add an event handler and the simplest way to provide an example. For better separation of concerns, you could instead use either a DOM0 onclick
property, addEventListener()
/ attachEvent()
or a library.