Unable to find href of new window using javascript
<p>I am using below mentioned script to get href of new opened window, but its not working </p>

<p>Browser FF 7, IE 9, WIN 7</p>

<p>Can someone please let me know what's wrong in the script</p>

<p>Thanks in Advance</p>

<p>Akhil</p>

<pre><code>    &lt;html&gt;
    &lt;head&gt;

    &lt;script type="text/javascript"&gt;
    function open_win() 
    {
      var mywindow=window.open("http://thesun.co.uk");
      var clbutton=document.createElement("button");
      var par=document.getElementById("main");
      clbutton.setAttribute("id","focus");
      clbutton.setAttribute("value","CLICK");
      clbutton.innerHTML="CLICK";
      par.insertBefore(clbutton,null);
      clbutton.onclick=function() {alertMsg(mywindow);}
    }
    function alertMsg(mywindow)
    {
  mywindow.focus();
  var t=mywindow.location.href;
  alert(t);
  //mywindow.alert("testing");
  mywindow.close();
    }

    &lt;/script&gt;
    &lt;/head&gt;

      &lt;body onload="open_win()"&gt;

         &lt;p id="main"&gt;&lt;/p&gt;
      &lt;/body&gt;

    &lt;/html&gt;
</code></pre>
