faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

20 of 33 people (61%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

I would like to make a message pop up when the user tries to exit a page saying please logoff properly, then return to the original page. How?

Apr 4th, 2008 20:01
ha mo, Jean-Bernard Valentaten, Martin Tuncaydin,


Try adding this little sample to your page:
function dontLeave() {
  var tmp = window.location.pathname;
  alert('Please logoff properly');
  location.href = tmp;
}
and then have it fired by the eventhandler:
<body onunLoad="dontLeave();">
You might have to dynamically have the body-Tag rewritten by the logoff-
function, else you won't be able to leave the page :)
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com