JavaScript サブウィンドウを生成する
<script type="text/javascript"> //サブウインドウを表すWindowオブジェクトを格納する変数 var subwin; //サブウィンドウを開くボタンクリック時に実行 function win_open(){ subwin = window.open('http://www.wings.msn.to/', 'Sample', 'width=600,height=300,scrollbars=yes,location=yes'); } //サブウィンドウを閉じるボタンクリック時に実行 function win_close(){ //変数subwinが空でなく、サブウィンドウが閉じられていない時にのみクローズ if(subwin && !subwin.closed){ subwin.close(); } } </script> <input type="button" value="サブウィンドウを開く" onclick="win_open()"/> <input type="button" value="サブウィンドウを閉じる" onclick="win_close()"/>
改訂新版JavaScript本格入門 ~モダンスタイルによる基礎から現場での応用まで
- 作者: 山田祥寛
- 出版社/メーカー: 技術評論社
- 発売日: 2016/09/30
- メディア: 大型本
- この商品を含むブログを見る