js 調(diào)用父窗口的具體實現(xiàn)代碼
更新時間:2013年07月15日 18:06:35 作者:
想要實現(xiàn)如題所示:父窗體需要頂一個show()方法,具體實現(xiàn)代碼如下,感興趣的朋友可以參考下哈,希望對大家有所幫助
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>
父窗體需要頂一個show() 方法
父面頁代碼:
復(fù)制代碼 代碼如下:
<!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 代碼 需要打開的頁面
復(fù)制代碼 代碼如下:
<!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>
相關(guān)文章
Javascript獲取CSS偽元素屬性的實現(xiàn)代碼
這篇文章主要介紹了Javascript獲取CSS偽元素屬性的實現(xiàn)代碼,需要的朋友可以參考下2014-09-09js 獲取網(wǎng)絡(luò)圖片的高度和寬度的實現(xiàn)方法(變通了下)
簡單地說就是把圖片放入一個自動伸縮的DIV中,然后獲取DIV的寬和高!這個不錯的變通,大家可以參考下。2009-10-10最全正則表達式總結(jié):驗證QQ號、手機號、Email、中文、郵編、身份證、IP地址等
這篇文章主要介紹了最全正則表達式:驗證QQ號、手機號、Email、中文、郵編、身份證、IP地址等,通過語法介紹作用表達式等詳細解釋了正則表達式的使用,具體操作步驟大家可查看下文的詳細講解,感興趣的小伙伴們可以參考一下。2017-08-08