看看下面这个例子,不知是否有帮助:
<HTML>
<HEAD>
<TITLE>Window Manger</TITLE>
<LINK REL="stylesheet" HREF="../samples.css" TYPE="text/css">
<SCRIPT LANGUAGE="JavaScript">
// Create an array to hold references to the child windows.
/* Each member of this array will be a window object created
using the createWindow method below. */
var windows = new Array();
function newWindow(url, wname) {
// Constructor for the window.
/* This function should be called only by the createWindow
function below. */
var features = "";
if (null != arguments[2])
features = arguments[2];
return window.open(url, wname, features);
}
function createWindow(url, wname) {
// Add a window to the windows collection.
var features = arguments[2] == null ? "" : arguments[2];
windows[wname] = new newWindow(url, wname, features);
}
function closeWindows() {
// Close all the windows opened by addWindow.
/* To close an individual window,
its close method is called. */
/* This function should be called during the onunload
event to automatically close all open windows. */
for (w in windows)
if (!windows[w].closed)
windows[w].close();
}
/* The following two functions demonstrate using the
createWindow and closeWindows methods. */
function listWindows() {
// List the windows and their current states.
var swin = "Window List\n";
for (w in windows)
swin += w + ":" +
((windows[w].closed) ? "Closed" : "Open") + "\n";
alert(swin);
}