onbeforeunload being called multiple times

Discussion in 'Javascript' started by saugust, Aug 16, 2006.

  1. saugust

    saugust Guest


    I am using the onbeforeunload as a way to indicate to the user that
    they have made some changes and to give them a way to stay on the page
    to complete their intended function.

    This is a very simple process that is well documented throughout the
    web. However, I have come across a problem that results in this event
    being fired multiple times. In my particular situation, my application
    has a tabbed UI where if a tab is clicked, a "redirect" function within
    JavaScript is called. The window.document is "replaced" with html that
    submits itself. The purpose is to take a particular URL and parse it's
    query string and make hidden input buttons that will be available
    within the Request object after the submit while keeping the same page.

    This is where the problem occurs as the onbeforeunload is fired when
    the window.document.open method is executed and all of the "write"
    methods for that window.document. If I try to attach/deattach or use
    variables to only allow one onbeforeunload event to be fired, the page
    still navigates away.

    Any ideas?
    saugust, Aug 16, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.