1. 程式人生 > >js建立子視窗,並通過子視窗操作父視窗的物件

js建立子視窗,並通過子視窗操作父視窗的物件

檔名:建立子視窗,並通過子視窗操作父視窗的物件.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>