views:

292

answers:

3

I need to open a popup window, which when closed, opens a new pop up window. Then when you close that one another opens.

I'm aware that this functionality can have uses for spam and nag-ware, but I need it for a user experience survey. Don't ask me, it wasn't my idea.

How do you do this?

A: 

Popup the first window have an onclose event in the first window that pops-up the second and an onclose event in the second that pops-up first. Have some sort of button on both pages that removes the onclose event so you can escape from it too.

Ollie Saunders
+6  A: 

The Javascript in the popup window can access the original window using the opener property.

Handle the onbeforeunload event in each popup window and call a function in the parent window to continue processing (and open the next window).

For example:

(In the original window)

window.onPopupClose = function(popupName) { /* ... */ };

(In each popup window)

<body onbeforeunload="opener.onPopupClose('someName');}> ... </body>

The popupName parameter is just an example, you can do whatever you want (such as having three different functions).

SLaks
Fascinating. I always wondered what even Meebo and Gmail use to ask you stuff when you try to close. onbeforeunload. Great, thanks.
Yar
A: 

Try :

<body onbeforeunload="javascript:window.open('Default.aspx','nsf','menubar=1,resizable=1,width=350,height=250');">

</body>
Himadri