中国开发网: 论坛: 程序员情感CBD: 贴子 696394
张秋桥: 我测试了可以。其实就是你的办法。一样的。
我的测试文件,两个HTML.
我修改了close函数成test();
就是改变一下新页面里的字的颜色。

<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].test();
}

/* 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);
}

function openSampleWindows() {
// Open two windows.
createWindow("closeme.htm", "ChildWindow1");
createWindow("closeme.htm", "ChildWindow2");
}
</SCRIPT>
</HEAD>
<BODY ONUNLOAD="closeWindows();">
<H1>Window Manager</H1>
<FORM>
<INPUT TYPE=BUTTON ONCLICK="openSampleWindows();"
VALUE="Add Windows">
<INPUT TYPE=BUTTON ONCLICK="listWindows();"
VALUE="List Windows">
<INPUT TYPE=BUTTON ONCLICK="closeWindows();"
VALUE="Close Windows">
</FORM>
</BODY>
</HTML>

另一个:Closeme.htm

<H1>Sample Window</H1>
<script type="text/javascript">
function test()
{
document.getElementsByTagName("h1")[0].style.color="red";
}
</script>

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录