Forum Moderators: open

Message Too Old, No Replies

call a function when someone Leaves your site

might be simple question, might be tricky

         

Anyango

8:09 am on Jan 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey Folks

let's say i want to display a popup when someone leaves a webpage of mine, no biggie. But what actually i want to do is if someone leaves my DOMAIN only then show popup, dont show popup if visitor has clicked on a link that leads to another page of my same domain

for example

on example.com/abc.html someone clicks on a link

example.com/p2.html

then popup shouldnt be shown but if someone clicks on a link that leads to

anyotherdomain.com/anypage.html or if they try to quit window only then show popup.

any ideas? i have an idea in which we can set value of a variable as false for insite links and in popup function could write if that variable is tru then dont show popup, but thats not what i am looking for. There are 100s of links on each page and are hundreds of dynamic pages on that site so i simply cannot change all those links to call a javascript function.

Basic Logic is

1) Call a function on body unload
2)someway or other findout if user is navigating to same site's any other page or is going offsite/closing window?
3)show popup only in second case.

Any suggestsions that could help me with Item # 2 would be really appreciated.

Regards

Bernard Marx

9:49 am on Jan 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only time you can know a visitor's navigation destination is when they click on a link. You can attach your function to all outbound links. AFAIK that is all you can count on.