構文
 
  window.opener
総合 インデックス
プロパティ
FirefoxIE

説明

  • 元のウィンドウを参照するプロパティ。

用例

HTMLファイル「a.html」から新しく開いた「Win_Open.html」内にあるボタンフォームをクリックしたとき,「a.html」を表示しているウインドウに「http://www.nikkeibp.co.jp/」のページを読み込む。
【a.html】
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>opener_1</title>
<script type="text/javascript">
<!--
function NewWin_1(){
	window.open("Win_Open.html","NewWin_1","toolbar=no,
location=no,directories=no,Width=400,Height=150");
}
//-->
</script>
<style type="text/css">
<!--
body { background-color: #ffffff; }
-->
</style>
</head>
<body>
*「open」メソッドで開いた元ウインドウ
<p>
<form>
    <input type="button" value="新しいウインドウを開く" 
onClick="NewWin_1()">
</form>
</p>
</body></html>

【Win_Open.html】
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>opener_2</title>
<style type="text/css">
<!--
body { background-color: #ffffff; }
-->
</style>
</head>
<body>
新しいウインドウ<br>
このウインドウを開いたウインドウにサイトを表示する。
<p>
<form>
<input type="button" value="日経BP" 
onClick="window.opener.location.href='http://www.nikkeibp.co.jp/'">
</form>
</p>
</body></html>

この用例を実行する

関連項目

---->windowオブジェクト/openメソッド
---->locationオブジェクト/hrefプロパティ