Save your Changes

The following is a neat little script that I found to remind people to save their changes when navigating away from a page (onBeforeUnload was developed originally by Microsoft for Internet Explorer, but then added to the new version of Mozilla Firefox). You’ve probably seen something similar to this when using GMail if you decide to close the window (or refresh or click the back or forward buttons) after starting to compose an email.

I researched this for a new Lyrek script that Mike and the Lyrek Developers are building to enables users to supervise the import of records and decide if they’re to be overwritten, discarded, merged, added as a new record or kicked off to the duplicate manager. It works in IE and FF. Sorry, no Safari support.

		<SCRIPT TYPE="text/javascript">
			window.onbeforeunload = function() {
			return 'You have unsaved changes. You will lose them if you continue.';
		<!-- Obviously put your page content here -->

Give it a try, it’s pretty clean, small and works well. Make sure you put the script inside your <BODY> tags.

Leave a Reply

Your email address will not be published. Required fields are marked *