Can we get the url of a new window which has been opened by window.open function? Lets say we open a new window and and change the url of this new window. Can we get the new url now?
Depends if the new URL is still within the same domain name. If it is, then you can. Otherwise, you can't (the browsers do not allow you to do this, for security reasons). var mywin = window.open('page2.html'); function checkUrl () { alert("Url is: " + mywin.location.href) } Code (markup):
hii the window.open function you called will always return a reference to the new child window that has opened. So through that object u can access many of the child window properties. Thus u can get the URL of the child window also. thanks Prasad
I have this script on a page: <script type='text/javascript'> var myWindow = window.open("http://www.google.com"); alert(myWindow.location.href); </script> PHP: IE doesn't give me any alert message at all and FF pops an alert with this text "about:blank" What is the problem then?
As I said earlier, if the URL in the child window has a different domain name, the browser doesn't allow you to access it anymore.