Window parentプロパティ
Window オブジェクト
定義と使い方
parent プロパティは現在のウィンドウの親ウィンドウを返します。
構文
window.parent
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザが parent プロパティをサポートしています。
例
例
新しいウィンドウを開いたとき、親ウィンドウに警告を表示します:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.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>サンプル(example.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>
試してみる »
Window オブジェクト その他の拡張