Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1475 How do I show a confirm box when the user closes their browser manually as I'd like to remind users to log out of my webpage properly before closing their browser?

You are here: irt.org | FAQ | JavaScript | Window | Q1475 [ previous next ]

By then it would be too late. The only event is the onUnload event and that is triggered even when they leave the page for another one of your pages. You would need to have a test in every link on your page:

<BODY onLoad="closing=true" onUnload="if (closing) alert('please leave next time by logging off')">

<a HREF="otherpage.html" onClick="closing=false">other page</a>

Feedback on 'Q1475 How do I show a confirm box when the user closes their browser manually as I'd like to remind users to log out of my webpage properly before closing their browser?'

©2018 Martin Webb