Take the 2-minute tour ×  When a user leaves one page of my
website, there should be a warning message which gives the user
the option to stay on the page:  "Are you sure that you want to
close this page?"  It doesn't matter if the next page is an
internal or external page.  I thought this could be done with
the onUnload event handler, couldn't it?  <body
onunload="confirmClose()">  The confirmClose() function must
then show a message box with two buttons so that the user can
choose between "Really leave" or "Stay".  function
confirmClose() {     return confirm('Really leave this page?')
But this function can't stop the unload, right?  Do you have a
solution for my problem? Thanks in advance!  share|improve this
question I have a solution to your problem: don't ask the user
to confirm leaving your site. It's nothing but annoying. –  Sean
Bright Dec 28 '09 at 17:50 There are legitimate uses for this,
for example when there is user input that would be lost when
leaving the page. –  Pekka 웃 Dec 28 '09 at 17:51