Window parent 屬性

定義和用法
parent屬性返回當(dāng)前窗口的父窗口。
語法
window.parent
瀏覽器支持
所有主要瀏覽器都支持 parent 屬性
實(shí)例
實(shí)例
當(dāng)打開新窗口時,在父窗口彈出警告:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
</head>
<head>
<script>
function openWin(){
window.open('','','width=200,height=100');
alert(window.parent.location);
}
</script>
</head>
<body>
<input type="button" value="打開窗口" onclick="openWin()">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
</head>
<head>
<script>
function openWin(){
window.open('','','width=200,height=100');
alert(window.parent.location);
}
</script>
</head>
<body>
<input type="button" value="打開窗口" onclick="openWin()">
</body>
</html>
嘗試一下 ?

更多建議: