0
有沒有什麼辦法可以檢測到我打開的那個彈出窗口是關閉還是不關閉?如何檢查打開的窗口是否用javascript關閉?
<script type="text/javascript">
// global variable for subwindow reference
var newWindow;
// generate and fill the new window
function makeNewWindow() {
// make sure it isn't already opened
newWindow = window.open("http://www.google.com","sub","status,height=200,width=300");
}
function checkWindow() {
if(newWindow.closed){
document.write("Window has closed.");
}
}
</script>
<form>
<input type="button" value="Create New Window" onclick="makeNewWindow();" />
<script>
checkWindow();
</script>
</form>
我希望當我關閉打開的窗口。函數checkWindow()在「窗口已關閉」屏幕上打印。請給我一些幫助代碼。在此先感謝