Window parent 屬性

定義和用法
parent屬性返回當前窗口的父窗口。
語法
window.parent
流覽器支持
所有主要流覽器都支持 parent 屬性
實例
實例
當打開新窗口時,在父窗口彈出警告:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</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>IT研修(xuhuhu.com)</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>
