您的位置:首页 > Web前端 > JavaScript

js创建子窗口,并通过子窗口操作父窗口的对象

2016-05-25 18:16 507 查看
文件名:创建子窗口,并通过子窗口操作父窗口的对象.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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: