1

我目前有以下代码来生成一个新的子窗口。我还为用户设置了响应超时,当超时结束时,子窗口应该关闭。

这是我到目前为止得到的:

 var zerominutpopup 'http://www.somewebsite.com/';
zerominutpopup = open(zerominutpopup, '', 'height=300,width=600,left=300,top=300');
setTimeout( function(){ timer_is_at_zero_hold(zerominutpopup); }, 10000);


function timer_is_at_zero_hold(windowtoclose){
windowtoclose.closed;// this is how (i thought) closing a window is done but doesnt seem to work.
}
4

1 回答 1

5
var chWnd = window.open(...);  //open window and save a reference to it

chWnd.close();   // use that reference to access that 'window' object's members

所以你的原始代码应该看起来像..

var zerominutepopup = window.open(url, '', 'height=300,width=600..');
setTimeout( function(){ 
    zerominutepopup.close(); 
}, 10000);
于 2012-09-13T08:56:01.613 回答