js 调用父窗口的具体实现代码

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

js 调用父窗口的具体实现代码

  2020-05-13 我要评论
opener.show();
父窗体需要顶一个show() 方法
父面页代码:
复制代码 代码如下:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD LEVEL1//EN">
<html>
<head>
<title>html.html</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>

<div>
<button id="btn">open new page</button>
</div>

<script>

window.onload=function(){

var btn = document.getElementById("btn");

btn.onclick = openPage;

function openPage(){
try {
window.open('newpage.html');
}catch(e){
alert(e);
}
//alert("ok");
}
}
function show(){
document.title=new Date();
}
</script>
</body>
</html>

newpage.html 代码 需要打开的页面
复制代码 代码如下:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD LEVEL1//EN">
<html>
<head>
<title>newpage.html</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<button id="btn" onclick="fun()">单击</button>
<script>

function fun(){
opener.show();
}

</script>
</body>
</html>

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们