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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alert when user attempts to close a window 2

Status
Not open for further replies.

mooster2

Programmer
Jan 26, 2004
21
CA
Hi,

Is it possible in Javascript to display an alert when the user tries to close a window?

Something like "Are you sure you want to close this window?"
 
This may only work in Internet Explorer, but place this script in the head section:

<SCRIPT LANGUAGE="JScript" TYPE="text/javascript" FOR=window EVENT=onbeforeunload>
mess = "ADDITIONAL MESSAGE OPTIONAL HERE"
return mess;
</SCRIPT>
 
this should work in IE and Mozilla (or at least firefox)

<body onbeforeunload="return 'your message here';">



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top