Hi,
I need to get the url of newly created window, which will be obtained by clicking a button. I have got current url by using document.url. Similarly I need to get the url of new tab or window which is generated by clicking a button.
How to get url of newly created window or tab on button clic
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


DRISHTY134 reputationPosted Sep 23, 2014, 3:51 AM EDT
var winX=window.open("newurl.htm","","width=100,height=50");
Then fetch child window url :
var x=winX.location.href;
alert(x);
Renjith V SRank #5,293 · 304 reputationPosted Sep 23, 2014, 4:05 AM EDT
var winX = window.open('http://www.google.com/images', "newStuff", "height=500px,width=500px");
var x = winX.location.href;
alert(x);
The alert is about:blank
DRISHTY134 reputationPosted Sep 23, 2014, 9:44 PM EDT
Try this :
var PopupUrl = "";
PopupUrl = 'http://www.google.com/images';
if(PopupUrl != "")
{
var doc=window.showModalDialog(PopupUrl, window,"scrollbars,resizable,width=500,height=400","");
alert(window.name);
}