I remembered a solution I did a couple of years ago where I simply added a before unload event to my body and some simple Javascript:
This works great... in IE, not in Firefox or Chrome though. The problem is that IE tracks the clientY mouse position and the other browsers don't, so a different solution was needed. I got some snippets off of the web for tracking mouse position and came up with this cross-browser solution and it works great. First, add the following Javascript to your page:
Next, add the following form to your page, this simply stores the mouse coordinates, you could use the var values, but I liked having these to debug and see what's happening.
That's it! Now you can warn users using any browser that they still have unsaved work. You will still need to monitor whether the page is dirty, etc, but this allows you to at least capture the event.
No comments:
Post a Comment