Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pop up when leaving website 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to have a pop-up occur when a visitor leaves my site without purchasing...a 'one last chance'. Does anyone have examples of how to do this?

Thanks!
 
Here is an "Exit Javascript" that I found at:


================================

When a visitor leaves your page, JavaScript can automatically open a new window. Use it to say "thanks for visiting", etc.

[1] First paste the javascript code into the HEAD of your HTML document:

[NOTE that I substituted [ for < in the first position]


[SCRIPT LANGUAGE=&quot;JavaScript&quot;>

<!-- Begin
function leave() {
window.open('pagename.html','','toolbar=no,menubar=no,location=no,width=720,height=170');
}
// End -->
</SCRIPT>


[2] Then copy the onunLoad event handler into the BODY tag of your HTML document:

<BODY onUnload=&quot;leave()&quot;>
 
Well, my first bit of advice would be to NOT DO THIS! simply because it is irritating.

That being said... heres some psuedocode:

onUnload function that checks the new location to see if your domain is in it (uses window.location.lastIndexOf(&quot;yourdomain.com&quot;)) and that checks a cookie to see if something has been purchased. If your domain isn't in the new url (if .lastIndexOf() returns -1) and the cookie says that nothing's been purchased, you'll open your popup.

you'll need another function so that after the user purchases something, you write a cookie saying so.

Give all that a try and lemme see what you have! -gerrygerry
Go To
 
I HATE popups when leaving a website, and so does everyone I've talked to about the idea. If you want to annoy people and make them not want to go to your website, this is one way of doing that. Popups when you enter a website are bad enough, and that's why the variety of popup killers are so popular now. I have never been to a website I'd consider &quot;professional&quot; that used onunload popups, and I'd probably consider one that did as not professional, or at least one to be avoided in future online shopping I did. Even the &quot;Thanks for visiting&quot; popups would fit into the category of unprofessional. Give me quality products at a fair price, ease of finding what I'm looking for, and ease of ordering, and you've got me as a customer. That's far more important than the &quot;one last chance&quot; popup that reminds me of the little kids who flock to my door as soon as I get home after a snowstorm to see if I'll pay them to shovel my walk and driveway (&quot;Please, please, PLEASE&quot;).

As you can see, this popup thing bugs me a lot, and I guarantee that I'm not the only one who feels this way with money in their pocket to spend online. I'd suggest you reconsider the idea, and spend the time making your site clean, easy to navigate, informative, and professional looking.
 
I should have acknowledged what both gerry and trollacious indicated at the start of their posts - that was an oversight on my part.

Unsolicited popups on exit to try to get the visitors attention are universally considered to be disastrous. For one thing, it is irritating. Secondly, it is a sign of &quot;desparation&quot;. So like them, I urge you to reconsider using such a device.
 
I hate popups when you leave sites too!!! [deejay]
Nate
&quot;If you're not living on the edge, you're taking up too much space!&quot;
 
Try this code on for size:
[COLOR=aa0000]
Code:
if (document.layers) document.captureEvents(Event.MOUSEUP);
document[document.layers?&quot;onmouseup&quot;:&quot;onclick&quot;]=function(e) {
 var s=e?e.target:event.srcElement;
 if (s.hostname && s.hostname != location.hostname && (s.target == &quot;&quot; || s.target == &quot;_self&quot; || s.target == null))
  alert('Bye!');
};
[/color]

It'll make a popup only if the viewer clicks a link to a domain other than your own. Keep in mind, though, that the only way it won't be annoying is if you don't want your viewers to return.
Code:
- UNIMENT
 
I agree with the others, I really hate popups when leaving a website. I don't care whether they try to sell me something, redirect me somewhere else, or just say &quot;Thank You&quot;, they're still annoying. If you want to thank people for visiting, do it on your HOME page, the first one they see. That will make a better (and less annoying) impression.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
gerrygerry gets a star for being the first one in this thread to say no to bad JavaScript pratices.

As JavaScript users we should not use JavaScript to annoy the heck out of users on any site anywhere.

OnUnload is evil and popups are evil. Combine them to ask a visitor anything (be it legitimate or even offer them a million dollars they will hate it).

You are walking down the street, someone pulls a knife at you and says : &quot;don't move!!!&quot;, startled and scared you don't move. The guy puts 100$ in your jacket pocket and runs away.

No one would say no to 100$ but if people go around giving it that way then we don't find it as much fun do we now?

Gary

Haran
 

The majority of websites that use popup windows are
either warez, porn sites or free personal web pages.
I'm not sure it would be a good idea to make your website
enter in one of the categories listed above.

Have a good day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top