Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Notify users before closing window

Status
Not open for further replies.

lyric0n

Technical User
Dec 28, 2005
74
0
0
I have a form that needs 3 pages of collecting information from the user, then passes it to me at the end.

I am having a problem with users closing out thinking they are done, when they really aren't. I need a way to send the user a popup warning them they are not finished if they attempt to go back or close the browser window, but do nothing if they continue on in the form.

I have tried using OnBeforeUnload with decent success, but am having trouble not having it pop up.

Any ideas?
Thanks.
 
would something like this work:
Code:
<body onUnload="if (!confirm('Are you sure you want to leave now?')) window.open(location)">
 
can you do an 'onBeforeUnload' - not sure if this is IE specific though!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
The easiest of examples is:
Code:
window.onbeforeunload = confirmExit;
function confirmExit(){
	return "This is the reason you should stay.";
}

Please note that if you have links inside the page and you don't want the box to keep popping up, you'll want to use other methods found here:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top