I am trying to force a new window on exit. _top does not work. The code below works but not for people who have popup disabled. I need this because in bye.php there are code to do a routine in database. So if someone is in a specific page and click on another link, I'd like to display bye.php instead, whichever link they click on.

<script language="JavaScript">
  window.onbeforeunload = bye;
function bye() {
window.open('bye.php');
}
</script>

    You could always change your links to use an outgoing page like:

    mydomain.com/goodbye.php?url=abcd

    Then your goodbye.php does your housecleaning, and after it's done, just shuffles them off to whatever URL they want (as specified by the $_GET variable "url").

    Otherwise, you could always just use a cron job to run every hour or every 1/2 hour depending upon your need.

      Thanks for replying. I ended up doing the onbeforeunload with ajax to send the request to a php.

      With IE 7 and other popup blockers that other solution was impossible.

        So what happens when they don't have JS enabled? Or they block your "onbeforeunload" event?

          bpat1434 wrote:

          So what happens when they don't have JS enabled? Or they block your "onbeforeunload" event?[/QUOT

          Then they cannot access the script at all. 😉

          How can they block the onbeforeunload?

            I'm not sure how they could, but that doesn't mean it can't be done 😉

              Everything is possible if you have security flaws. Entire sites do get hacked, right? :-)

                bpat1434 wrote:

                I'm not sure how they could, but that doesn't mean it can't be done

                Open the DOM window in firebug, go to the window object, and delete the property 🙂

                  Write a Reply...