Forum Moderators: open

Message Too Old, No Replies

Pop up .. on window close

I know it is not good.. I just need that

         

NeoN

7:11 pm on May 26, 2002 (gmt 0)

10+ Year Member



Hi all!
I HATE POP UPS!!

But one of my client insists.. :(

So, could you give me an example of the pop up window on page quit??
onUnload will not work!! THAT POP UPS even if you browse withing a site..
What I need is the pop up on site quit event.

So, only when somebody closes the winddow, not just the page browse jump.

Would be greatly appreciated!

Thank you!

ggrot

8:14 pm on May 26, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is no event that will trigger when someone leaves the site. The only way to do this would be to have onUnload call a function which checks the value of a javascript variable. If true, then popup, else do noting. Then have every link on the page have an OnClick property that changes this variable to false. Its a major pain to implement, but thats how you would go about it.

1Lit

9:25 pm on May 26, 2002 (gmt 0)

10+ Year Member



Any way of only popping-up if the surfer clicks the back button?

notsosmart

2:05 am on May 28, 2002 (gmt 0)

10+ Year Member



I've been looking for something like it for a long time. CNN does it when you leave their sites... for magazine subscription pop-ups...

I am not smart enough to figure out how, though.

NeoN

2:51 am on May 28, 2002 (gmt 0)

10+ Year Member



Ok, I found the elegant solution myself..

Use this JS in your head:
---------------------------
var exit=true;
function showPopup(){
if(exit){
var popup = window.open("popup.html",'Help','width=450,height=650,scrollbars=no,resize=no');
}
}
------------------------------Then use this in body:
<body onunload=showPopup() >

AND!! Now add the code below to all your links:
<a onclick=exit=false href=...

The last code makes the pop up not to come up when the user browses your site.. ALL INTERNAL LINKS SHOULD HAVE THIS!

This method has disadvantages, but works in 80%

Thank you all

tedster

3:22 am on May 28, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Related thread: [webmasterworld.com...]

It fills in some of the details.

I don't think there's any way to catch someone leaving your site with the Back Button