Forum Moderators: mack

Message Too Old, No Replies

pop up on exit

how to pop up a window when visitor leaves the site without clicking

         

johnd

9:41 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



how do I pop up a window when visitor leaves the site without clicking anything on it?

when they click on a link on the page, I do not want to pop a window.

i guess it has to be done using cookies?

robert adams

10:53 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



try this:

Full URL »
<body onunload="window.open('http://www.newpage.com')">

Relative »
<body onunload="window.open('page.htm')">

johnd

11:03 pm on Jan 15, 2004 (gmt 0)

10+ Year Member



thanks, but this code pops up a new window regardless if the visitor clicks any link on my page or not.

i want the window to appear only when a visitor closes my website without clicking anything.

robert adams

1:34 am on Jan 16, 2004 (gmt 0)

10+ Year Member



I don't understand. This opens a window when they leave your page. Isn't that what you wanted.

Karu

5:02 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



Maybe you can call a user function in the body-unload, instead the window.open itself.
I mean, call a function, and at the begining of the function code, check if the user clicked something or not. If the user hasn't clicked anything, call the window.open, otherwise, do nothing.

Regards!

johnd

5:18 pm on Jan 16, 2004 (gmt 0)

10+ Year Member



Thanks, but how do I do all that?

DaScribbler

12:36 pm on Jan 17, 2004 (gmt 0)

10+ Year Member



Generate a cookie for each user who enters your site. Increment that cookie with every link. If the cookie is greater than 0 when they leave you'll know they've hit one of your links.

I'd go into more detail, but to be honest, pages that do this sort of thing really irritate the begeezuz outa me.

txbakers

10:08 pm on Jan 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please don't make duplicate posts. this post was also made in the Webmaster General forum. All the forums are widely read and there is no need for duplicates.

johnd

10:28 pm on Jan 17, 2004 (gmt 0)

10+ Year Member



the post in the Webmaster General forum is not mine. that's some other user. plus, it's about setting a startpage.

Stefan

10:58 pm on Jan 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Exit pop-ups will p*ss off everyone who visits your site. Why would you want to do that? You're hijacking people's browsers, man, and no one likes it. Why do you think there are so many versions of pop-up blocking around?

WebDon

5:11 am on Jan 18, 2004 (gmt 0)

10+ Year Member



First of all, if you can avoid it, DON'T do it. Pop-ups and pop-unders have really created problems. It's to the point where I even avoid using a target=_blank for fear of it not working with a pop-up blocker.

That said, I spent a lot of time on this not too long ago. My client really wanted a particular window to pop up ONLY if someone closed the browser and NOT when they clicked a link or anything else...and the customer is always right, right?

The end result of my search/research is that you can mimick it to a point, but realistically it's not possible. The problem that I found is that any script you're running in the document to monitor when the window is closed is killed when the window is closed. It would be like asking you to call me when you die. You can't call until you're dead cause until then you haven't died...but can you call me when you're dead? That would be a neat trick.

For information on how to mimick it (i.e. keep the links from triggering the pop-up) search the JavaScript forum. There are a couple of examples there.