Using javascript, one of the things I need to do is when a button is clicked on my index page, a new webpage (new window) is opened. This new webpage redirects to another webpage and with the setTimeout() function, I close the new window and focus back on the original index. My question is if there is a way to extract the URL of the redirected webpage so I can use it in my original index.
I tried,
winRef = window.open(url+param);
winRef.focus();
loc = window.location;
setTimeout("winRef.close()", 3000);
but this obtains the URL of my original index page (not the redirected page I need). Is there a way to do this? Thanks.
Surely you need
loc = winRef.location;, rather thanloc = window.location;, assumingwinRefis the window you are opening. You also may need to do this inside the timeout, because the redirection won’t have happened straight away.You will only be able to do this if the redirected page is on the same domain as the page you are on. If it redirects to another domain, security will prevent you seeing the new URL. If you have control of the page that is being redirected to, you could cause it to signal to the original page by changing it’s hash.