Web Analytics Made Easy -
StatCounter onbeforeunload question - CodingForum

Announcement

Collapse
No announcement yet.

onbeforeunload question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • onbeforeunload question

    <script language="javascript">
    var displayPrompt=true;
    </script>
    <script language="JavaScript" event="onbeforeunload()" for="window">
    if (displayPrompt){
    event.returnValue = "Message here";
    }

    This will prompt the user and ask if they really want to leave the site. It is invoked whenever the current page is changed.

    Is there a way to set it to only be invoked when either the browser window is closed, or when a new URL is put into the address bar? Or should I be using a different event handler.

    I realize that I can put an onClick displayPrompt='false' for each <a href="">, but the DHTML menu that I use won't work correctly if I do so.

    Thanks.
Working...
X