view raw
wtm wtm - 5 months ago 66
Javascript Question

Javascript close an tab you just opened

I want to open a URL in a new window, and after x seconds or when the page is done loading I want to close it again.

I am now using:'', 'newwindow', 'width=300, height=250'); return false;

The 'otherurl' is not domain, so I cannot control that URL.

How can I do this?

Answer gives you a reference to that window, so:

var newWindow ='', 'newwindow', 'width=300, height=250');

setTimeout(function() { newWindow.close(); }, 5000);