Re: Launching Popups when Leaving a Site
by "Mike Taylor" <lonewolf(at)one.net>
|
Date: |
Wed, 27 Mar 2002 22:38:04 -0500 |
To: |
"HWG Languages \(E-mail\)" <hwg-languages(at)hwg.org> |
References: |
|
|
todo: View
Thread,
Original
|
|
I think there's some clarification needed here.
The issue of these pop-ups is not how to use OnUnload to create a pop-up
window, but how to make the OnUnload event handler be intelligent enough to
know the *difference* between closing your browser, typing in a new URL to
the site, hitting the refresh button or clicking a link that goes off your
site. Any one of those will trigger OnUnload, but if you've got a picky
boss who wants the pop-up to appear ONLY when the user leaves the site, and
NOT when any of the other conditions mentioned above occur, then the issue
becomes far trickier.
You can, as someone suggested, include a little bit of code attached to
every single link on your page that calls a function checking to see if that
value is set and then trigger the pop-up that way. The problem with that is
that every page on your site that you want this pop-up would need to have
every single link include a reference to the JavaScript function --a tedious
prospect, to be sure. Worse still, it doesn't cover the instance of someone
simply typing a new URL directly into the address field of the browser.
You could use a frameset, which would then have the OnUnload event handler
on only the main page, which would be open all the time so long as they are
on your site, but this also has problems. 1. Frames used in this
fashion..well..suck. 2. You'll inevitably get complaints from either
internal staff or from customers who are used to highlighting and copying
URLs directly from the address field of your browser. But if you have
frames, the URL in that field never changes, no matter what page they go to
on your site.
The fact is that OnUnload *by itself* is incapable of knowing the difference
between all the aforementioned conditions. Time.com (and any major site
affiliated with Time-Warner), incorporates a very intense set of scripts
that check for every major contigency. They seem to achieve this because 1.
Time owns everything and can afford using scripts across different domains
to work together to achieve their pop-up magic and 2. they use several
different methods beyond OnUnload to reach their goal.
Mike
HWG: hwg-languages mailing list archives,
maintained by Webmasters @ IWA