View Full Version : closing popup windows
Bluemonkey
09-12-2002, 04:40 PM
is there a way of naming popup windows and haviong a button close all windows before it opens a new popup window?
thanks for the help
beetle
09-12-2002, 05:19 PM
Sure, but you HAVE to know the name of the window, or use a reference variable.var win1 = window.open('http://www.google.com','_blank','');
var win2 = window.open('http://www.msn.com','_blank','');
var win3 = window.open('http://www.php.net','_blank','');
function closeWins() {
for (var i=0; i<arguments.length; i++)
eval(arguments[i]+'.close()');
}Now add this event to any elementonClick="closeWins('win1','win2','win3');"
glenngv
09-13-2002, 10:49 AM
Originally posted by beetle
Sure, but you HAVE to know the name of the window, or use a reference variable.var win1 = window.open('http://www.google.com','_blank','');
var win2 = window.open('http://www.msn.com','_blank','');
var win3 = window.open('http://www.php.net','_blank','');
function closeWins() {
for (var i=0; i<arguments.length; i++)
eval(arguments[i]+'.close()');
}Now add this event to any elementonClick="closeWins('win1','win2','win3');"
you could have passed the window handles as objects not as strings so that you won't need to eval() them.
function closeWins() {
for (var i=0; i<arguments.length; i++)
arguments[i].close();
}
onClick="closeWins(win1,win2,win3);"
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.