Click to See Complete Forum and Search --> : HELP, how to get URL of popup


kjunk01
10-06-2005, 08:51 PM
I have an index.html has a link that popup a window with a target name of main_browser. How can I have index.html grab the url of the popup window main_browser.

pccode
10-07-2005, 12:12 AM
Generally you would use the window.location command to grab the url of a window. Unfortunately I'm not sure if it's possible to use that command to grab the url of a different window. If you wanted to get information from a different frame you would use parent.frames[0].document.form[0].name.value. Perhaps there's a similar command to grab information across different windows.

As a temporary solution you could always create a function that would set the popup's location to a variable. Something like this:


function setLocation(url) {
window.open(url, "main_browser");
var address = url;
}

<a href="javascript:setLocation('popupwindow.htm');">Open Window</a>


The address variable will then contain the window location.

webstuff
10-07-2005, 11:12 AM
if it was called from the parent document, yeah, if it arrived as an independent popup as in a popup advert, you wouldnt as the window and instance of iExplore would be independent of each other.

felgall
10-07-2005, 05:51 PM
If you open the window like this:

var popwin = window.open(url, "main_browser");

You can reference the URL of the page displayed in that window like this:

popwin.location.href