Javascript: how to open a page then wait for few seconds open another page in the same window
<p>I tried to open an url in a window then wait for few seconds and opened another url in the same window. But the script doesn't work. When run it gives a blank window. I am new in Javascript. Can someone please help me?</p>

<p>I want to run it in Google Chrome as well.</p>

<p>The script is as follows:</p>

<pre><code>my_window=window.open("","mywindow");
my_window.location="http://www.yahoo.com";
sleep(10000);
my_window.location="http://www.youtube.com";
sleep(10000);
my_window.close();

function sleep(delay)
{
    var start = new Date().getTime();
    while (new Date().getTime() &lt; start + delay);
}
</code></pre>
