文件名:创建子窗口,并通过子窗口操作父窗口的对象.html
文件代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>创建子窗口,并通过子窗口操作父窗口的对象</title>
<script language= "JavaScript">
function fun(thisurl){
window.open(thisurl,"页面标题","width=470,hight=15,scrollbar=yes,resizable=no");
}
</script>
</head>
<body>
<input type="button" value="打开" onClick="fun('openerdemo.html')">
</body>
</html>
文件名:openerdemo.html
文件代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>创建子窗口,并通过子窗口操作父窗口的对象</title>
<script language= "JavaScript">
function closeWin(thisurl){
window.close();
}
window.opener.location.reload(); //刷新父窗口页面
</script>
</head>
<body>
<h3><a href="#" onClick="closeWin()">关闭窗口</a></h3>
</body>
</html>