onbeforeunload being called multiple times

S

saugust

Hey:

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?
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top