# "Do you really want to leave this site" <---- how to create something to do this?



## BonniC (Jul 10, 2008)

I have a client who is requesting a "pop-up" using a program (he suggested freeware... sigh...) or a script or even programming to create something that would do the following...

A person visits his site www.anysite.com.
They leave the home page shortly after landing.
As they go to leave the site, a message (pop-up? script?) would appear with a message (something like "did you find the information you needed" or something similar that can be customized.)

In addition to that, he would like:
1) the "pop-up to appear on any page that the visitor leaves
2) possibly having each page having a customized message
3) and being able to apply this message to specifics such as the length of time on the site and/or page,
4) as well as the distance of the visitor from the office (ie 250 miles)

I have only seen "pop-ups" asking me if I was sure I wanted to leave the site. But my pop-up blocker usually blocks stuff like that.

I personally have NO idea what kind of program, script, or programming language could/would be used to do this. I know he wants something free (yea, right!), but I would not even know where to start.

Can anyone help me with this? Or direct me to a site, program, etc to give me some ideas? If programming is needed, what would be used?

For the record, his website is strictly HTML (with some javascript)... it is nothing fancy... just a LOT of pages with text and pics.

I appreciate anyone's help and/or guidance!!

Bonni


----------



## madd74 (Nov 9, 2003)

http://www.htmlgoodies.com/primers/jsp/article.php/3478221

The problem with using a script like this is that people such as myself that block all pages javascript until I trust a page, it is not ever going to be triggered (unless I add the site in question).

Pretty much, you could use an alert also:

http://www.faqs.org/docs/htmltut/document/_BODY_onUnload.html

Just remember, in doing what he wants to do, he could end up annoying a LOT of people who visit. I know if I had something like that on my forums, each time someone click a link to post, read, move to another forum, etc, that an alert box would pop up each and every time.


----------



## namenotfound (Apr 30, 2005)

I agree with madd that it would annoy a lot of people. I for one, would just leave the site and never return if I got a pop-up every single time I left the page to go to another page on the site.


----------



## TheRobatron (Oct 25, 2007)

Some sites use a server-side redirection page, where instead of linking to an external site they link to a local file, sending the external URL, such as redirect.php?url=www.google.com. Then redirect.php can say "Are you sure you want to leave? etc" and there is usually a direct link to that site saying "Proceed" or a timed Javascript redirection.

This involves more work as you have to change every external link (or write a script to do that for you) but it's garaunteed to work. Also I do agree that popups are very annoying and you'd be better off just using target="_blank" for external links, so the original site remains open.


----------



## namenotfound (Apr 30, 2005)

TheRobatron said:


> Some sites use a server-side redirection page, where instead of linking to an external site they link to a local file, sending the external URL, such as redirect.php?url=www.google.com. Then redirect.php can say "Are you sure you want to leave? etc" and there is usually a direct link to that site saying "Proceed" or a timed Javascript redirection.
> 
> This involves more work as you have to change every external link (or write a script to do that for you) but it's garaunteed to work. Also I do agree that popups are very annoying and you'd be better off just using target="_blank" for external links, so the original site remains open.


Those link have the risk of giving your site a bad name though. Like let's say you owned goodsite.com and someone used your redirecting file to link to a bad site, such as goodsite.com/redirect.php?url=badsite.com

People will think it's your site giving them the virus or whatever there is on "badsite.com"


----------



## TheRobatron (Oct 25, 2007)

namenotfound said:


> People will think it's your site giving them the virus or whatever there is on "badsite.com"


That's why most of these pages have disclaimers on them and make it clear that the user is leaving the site - the purpose of them is to avoid your site getting a bad name


----------



## madd74 (Nov 9, 2003)

i see what namenotfound is saying, and think the only way to get around that is you would have to predefine what links could end up getting redirected in the script that way someone else could not use just any site to redirect it.

One thing that may NOT be so annoying, only a little, is if you used a script that relied on cookies so that once you click on a link, it gives you the message that you are going to be redirected to an external link, and then it remembers your selection so any time you click on that same link as long as you have cookies set you do not get the popup every time.

This problem, however, lies in people who do not accept your cookie, or who clean up their cookies often


----------

