Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture Opener URL?

Status
Not open for further replies.

JJHenry

Programmer
Apr 18, 2005
3
US
Hello!

I have a very simple HTML page that contains a button that does a window.open to access an asp on our webserver. In that asp I'm trying to capture the URL of the opener window. I then want to search through that URL for a specific string.

Can someone give me some tips on how to accomplish this? I'm very new to Javascript so I'm not sure how to actually capture the window.opener URL. I've tried just assigning the window.opener.location to a String variable but it doesn't work.


TIA!
 
>I've tried just assigning the window.opener.location to a String variable but it doesn't work.
The problem is that it is not a string right away. Do this.
[tt]
if (window.opener && !window.opener.closed) {
var x=window.opener.location.toString();
//or
var y=window.opener.document.URL;
} else {
//whatever to do without x or y
}
[/tt]
 
Thanks for your reply! I plugged that sample code into my asp and customized it, however, I still can't retrieve the location ... my code is listed below. What have I done wrong?

if (window.opener && !window.opener.closed)
{
window.alert('Opener Exists');

window.alert('trying to retrieve URL');

var windowLoc=window.opener.location.toString();

//THE FOLLOWING ALERTS ARE NOT DISPLAYED??
window.alert('trying to display URL');

window.alert(windowLoc);

}
else
{
window.alert('no opener exists');
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top