...

View Full Version : pop-up that closes parent window



yombull
03-15-2004, 03:47 PM
I have an exit window on a web page, when clicked it has a question asking if you are sure you want to exit this site, with buttons for yes and no. I would like the yes button to close botht the pop up and the parent window, and no to just close the pop-up. How would I go about doing this?

Thanks

Roy Sinclair
03-15-2004, 04:14 PM
window.opener.close();window.close();


Good practice though is to never close a window you didn't open, the user can use the regular window close mechanism to close any window they want at the time they want and trying to close any window you didn't open is going to cause the user to get asked if they want that window to be closed.

That extra prompt can be bypassed but that's a bug you can't count on being there so don't bother with trying to take advantage of it because while it'll make your website look smooth now it'll be fixed someday and then your website will look awkward.

Some good advice: http://evolt.org/article/I_am_USER_hear_me_roar/4090/60295/index.html


EDIT: Had to fix my code a bit :o



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum