View Full Version : close pop-up using window.close()
05-16-2009, 11:41 PM
greetings. first post here. thanks in advance for any help.
I am using the following code in to open a pop-up window (in Flash hence the actionscript tags ..):
This is working fine. My problem is how to close this window from other pages on the website.
I have tried:
05-17-2009, 01:45 AM
Not sure you can close a window that was opened from Flash, but if you can...
One not-so-well-advertised fact is that you *can* "find" a window on a page by its name, assuming that your code opened it.
So you could do:
var radioWin = window.open("","radio");
if ( radioWin != null ) radioWin.close( );
Note that you don't pass a URL to the window.open. In this usage, *if* the window of that name already exists, you get a handle to it.
Caution: If the window of that name does *NOT* exist, this code will open one (blank) very briefly until the close( ) then closes it.
NOT TESTED IN ALL BROWSERS! Works in MSIE and FF.
Note: YOU must be the "owner" of the popped up window, of course. That is, your code must be. That's why I worry about invoking this from Flash: Not sure whether the browser sees Flash as same "owner" or not. I'd be curious to know if it works.
05-17-2009, 03:45 AM
that worked perfectly!!! i was stuck on the name assign from the pages to close the window. thank you so much!
05-17-2009, 03:56 AM
Always liked that trick, OP.
Thanks for helping the OP.
btw is it just me, or is someone playing with the buttons around here?
05-17-2009, 06:30 AM
Oh, it's probably me.
My wife says I'm always leaving the second from the top button of my shirt unbuttoned.
Yeah, and the icons have changed color a bit, too.
Probably installed a new version of the forum code.
CaliCoder: Thanks for confirming that it works even from Flash.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.