Neta Meta
Neta Meta

Reputation: 4047

Closing a child window from it's parent

I currently have the following code to generate a new child window. i also set a timeout for the user to respond , when that time out ends the child window should be closed.

Here is what i got so far:

 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.
}

Upvotes: 1

Views: 1597

Answers (1)

Robin Maben
Robin Maben

Reputation: 23114

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

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

So your original code should look like..

var zerominutepopup = window.open(url, '', 'height=300,width=600..');
setTimeout( function(){ 
    zerominutepopup.close(); 
}, 10000);

Upvotes: 5

Related Questions