JavaScript Windowが未だ開いているか
ナビゲーションに移動
検索に移動
JavaScript Windowが未だ開いているか
<html> <head> <script> var winobj; var check_cnt = 1; var timerId; function openLink( url ) { var winname = "dummy"; winobj = window.open(url, winname); timerId = window.setInterval(checkStatus, 1000); } function checkStatus() { var area = document.getElementById("win_status"); var isClosed = false; try { isClosed = winobj.closed; } catch(e) { isClosed = true; } if (isClosed) { window.clearInterval(timerId); } var winStatus = (isClosed)?"<span style='color:red;'>CLOSED</span>": "<span style='color:blue;'>OPEN</span>"; area.innerHTML = "確認回数(1.0秒毎) : " + (check_cnt++) + "回, Windouwの状態 :" + winStatus; } </script> </head> <body> <div id="win_status" style="border: 1px solid red;width:500px;height:20px;"> </div> <a href="javascript:openLink('http://google.co.jp');">google</a> </body> </html>
© 2006 矢木浩人