Link to home
Start Free TrialLog in
Avatar of junglenative
junglenative

asked on

Pop-up when user leaves domain

Hello,

Is there an easy way to find out when user leaves my domain? I have looked around and havent found an easy way... CNNSI.com and FORTUNE.com use javascript to do it but is very complicated. I need to pop-up a page when a user leaves my domain (not the page).

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of lil_puffball
lil_puffball
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of neongrau
neongrau

hi!

this is a tricky one. but i have an idea...

put your whole site into a frameset consinsting of 2 frames. one of them has a height of 0px so its invisible to the user. put a page into this invisible frame with an unload event that opens your popup.

when you're navigating insider your domain you won't leave the frameset and no event gets triggered. but if the user closes the window or types a new url manually... voila!

~neongrau
Avatar of junglenative

ASKER

Thanks for your answers,

lil_pufball - That works, but I want it only to work when the user leaves the domain (my site) and not every page.

neongrau - I have tried that, and it works. But I have no way of knowing where my visitors come to (I dont have one landing page). I can put a check on every page to see if its in a frameset and if not then put it in one... but it gets pretty messy.

Is there any way of knowing where the user is going from the page?
sorry no, i don't think theres any way to get that information.

that't the reason why i took the frameset approach. even IE's special extension won't provide that information.

~neongrau
I know that there is a way though... if you go to CNNSI.com or FORTUNE.com, the popup works. It only pops up when you leave the domain, or close the browser. They have a cookie set so it only works once, you might have to clear cookies to recreate.

Thanks again for your help.
I know that there is a way though... if you go to CNNSI.com or FORTUNE.com, the popup works. It only pops up when you leave the domain, or close the browser. They have a cookie set so it only works once, you might have to clear cookies to recreate.

Thanks again for your help.
oh, is that what you meant? so sorry, i misunderstood! ;)

Well, what I'd suggest is use my code above, but on each of your pages place code so if there is a popup then you close it. this will get you the effect you want.
Thanks again lil_puffball,

The problem with that is the pop-up always pops up and then closes with every page. It gets annoying after a few of those. The only place I want the pop-up is at the check-out page (if they bail out). And I want it only to work if they go to some other domain or close the browser. The only thing I cant get to work is if they hit the back button. I can even get it to work if they click on any links on the page (I can put a flag with every link). SO the only problem I have is with the "back" button.
So what code are you using right now so that it works on everything except the 'back' button?
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: lil_puffball {http:#8037417}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer