homepage Welcome to WebmasterWorld Guest from 54.145.183.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
JS: Popup window on site exit
AndySimpson

10+ Year Member



 
Msg#: 168 posted 10:26 am on Jul 30, 2002 (gmt 0)

Hi,

Does anyone know how to make a popup window appear when a site is left or the browser is closed?

I've tried using the onUnLoad() method, but that pops up a window when each site page is left, rather than when the doamin is left.

Anyone have any ideas?

Andy

 

joshie76

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 168 posted 11:40 am on Jul 30, 2002 (gmt 0)

Nope, you can't tell the difference between an onUnLoad called by Refresh, closing the browser, typing in a new address, clicking a link in the same domain and so on...

You could stick javascript on every internal link on your site that cancels the onunload event but it still won't fix the problem for refreshes or people typing in another URL in your domain... forget it.

PS, Welcome to WebmasterWorld.

rewboss

10+ Year Member



 
Msg#: 168 posted 5:08 pm on Jul 30, 2002 (gmt 0)

You could try using a frameset -- you can have a frameset consisting of only one frame -- and using an onunload handler in the frameset. All your offsite links would then need target="_top" and this should, theoretically, work. There are other sneaky techniques, such as a small popup moved offscreen that periodically checks the closed property of the window in question.

However, it's a pretty damned annoying thing to do. It's what porn sites do to try to prevent you from leaving, and absolutely nobody likes it. (Not that I habitually surf porn sites, you understand...)

I reckon every popup loses you a sale. A popup on exiting might not lose you the sale, but it will almost certainly lose you any repeat business.

smatsmax

10+ Year Member



 
Msg#: 168 posted 5:17 pm on Jul 30, 2002 (gmt 0)

Using cookies i find that it doesnt annoy visitors too much
cos they only get shown the pop up once
Might be a solution

joshie76

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 168 posted 6:14 pm on Jul 30, 2002 (gmt 0)

Whilst Rewboss's frameset solution is a good one, you should note that it still doesn't fix the problems with a user refresh or typing in a URL on your domain. You have the added problem of squeezing users into the frameset even if they come through an SERP (Search Engine Results Page*). As you're probably beginning to see now, it's just not worth the trouble.

*Is that right? I've always just thought it stood for that...

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved