Forum Moderators: open
_____________________
1) From the HEAD section of every page, set some variable (let's call it leaving) to "true".
2) Also from the HEAD section, define your popup function so that it only launches a window after testing to see if (leaving = true).
3) Now include the onClick event handler in every internal link on the site, and set leaving = false. So, all your site's internal links should now look something like this:
<a href="stillmypage.html" onClick="leaving = false">Link Text</a>
4) Finally, within the BODY tag of each page, use the onUnload handler to call your popup function.
If an internal link was clicked, then the variable will be false -- and the popup window will not launch. However, if the page is unloading but an internal link was not clicked, the variable will be true and the popup will launch.
_______________
This approach fails if an internal URL is typed into the location bar, but that's not very likely. There is one major flaw I can see — using the Back button will trigger the popup window every time, whether the visitor is going "back" to one of your pages or not.
One is for a short survey of some kind. Using the exit pop-up up gives a more statistically valid set of results, or so this White Paper I was reading claimed. At least it eliminates some of the biases that other methods introduce into the sample.
The second use (some affiliate programs tout this) is to use the exit popup to pitch one last "deal". These programs claim some conversions on exit, and if the prospect was already leaving, any conversion at all is thought to be an improvement.
But the annoyance factor (and it's obviously there) would be pretty hard to measure. Maybe you could cookie visitors when the popup loads and see how many return. Then use the same JavaScript logic to place an exit cookie but no popup, and see how many of those return.
I've never seen any data on a scheme like that, however.
I can't think of a way.
Even if we could, we would want to set 'leaving = false' if the Back Button destination was still on the site, and 'leaving = true' if the destination was off site. And that kind of knowledge is not available to JavaScript, for pretty big security reasons.
Use a blur console that opens the pop up behind your page. It will stay there until manually closed down. The blur javascript is very easy.
<script language="JavaScript">
<!-- Hide script from older browsers
if(navigator.appName.indexOf("WebTV")==-1){
myWin=open('','winin','toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0,width=450,height=140');
myWin.blur();
myWin.location = 'http://whatever.htm';
}
// end hiding contents -->
Stick that in between Head and Head and you have a pop up that doesnt intrude to much on the surfers experince.
Problem: You can only use one (On each page?) - but more than one pop up is a waste. Also many surfers are turning off their javascipts - so the days of the pop ups are probably numbered.
Finally, most people are oblivious to pop ups - I for one rarely read them. I close them before they even are fully "popped up".
Hope this helps.
By the way can you use this on more than one page - so you have a blur pop up on each page. I dont have time to try it.
Regards
By using this "leaving variable" scheme to download a dedicated 1x1 gif (just cache it with a "new Image" script, not render it) I think we can compare newsletter pageviews to gif downloads and easily see how persuasive the newsletter is in drawing people further into the site.
Create a frameset as the homepage of your site with two frames. One frame will be your real homepage. The other is a static page used to maintain session state and is invisible (set the frame width or height to 0%)
In the session state page have the body onUnLoad event fire your pop up.
PROS: Easier to implement.
CONS: Need to be sure that visitors will always enter via the frameset page. This is fine for something like an intranet application but can be problematic for a website where people may clickthrough from a search engine direct to your real homepage etc...
This is a useful technique for web application development as you can also store various session state variables in the hidden frame. Particularly useful if you're developing for a web farm (where there can be serious problems with server-side session state variables).
If you wish to have a single popup which is triggered from multiple pages, you can put this code on as many pages as you like.
If you want multiple popups, simply change the second parameter to "something else" to popup different windows.
Hope that answers the question, and thanks for the posting. I used the use the Joshies frame method, but yours is more appropriate for my application. I'll post up the results after a few days.
To add another CON to joshie's approach - a big CON - with a frameset, anytime the user clicks REFRESH, it takes them back to the frameset page, not the page they are on. If there is a work around for this one, I'd love to use it, because that was the best solution for me so far.
I'm going to try the popunder approach next.
However if you are looking at returning customers, then forget about popups on exit. better using SSI's on relevenat pages to the search for daily deals as such, otherwise if you have a high return rate you will annoy whoever.