作业:按钮控制打开关闭新窗口及新窗口按钮关闭父窗口

父窗口 a.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>父窗口</title>
</head>

<body>

<input type="button" value="打开新窗口" onclick="zi=window.open('b.html', '子窗口','width=300,height=300 top=50,left = 100, scrollbars=yes, resizeable=yes, toolbar=yes,menubar=yes,location=yes');" />

<input type="button" value="关闭子窗口" onclick="zi.close();" />


</body>

 子窗口 b.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<input type="button" value="关闭父窗口" onclick="window.opener.close();">
</body>
</html>
原文地址:https://www.cnblogs.com/dirgo/p/4963334.html