Click to See Complete Forum and Search --> : How to pass a URL variable to a popup


rrobles
09-18-2003, 11:32 AM
I am using an ASP script as an option for sending a web page URL to a friend. I am using a javascript code to load a popup and do mail sending. I want to know how could I pass the HTTP referer or page URL to the popup so I could send the URL of the page that I want not the popup URL.

I will appreciate your help,

Sincerely,

Robles

Khalid Ali
09-18-2003, 12:00 PM
a popup is a child of the main window,therefore giving you almost complete access to its document.

You can pass a value from parent to child/child to parent very easily.

Suppose you have a variable parentVar in paent window and childVar in child window

access parent variable in child window

top.opener.parentVar

from parent

childWin.childVar

rrobles
09-19-2003, 09:23 AM
Khalid thank you for your answer but I didn't understand what you explained to me. I have none knowledge of javascript. My question is how do I grab my parent URL and pass it to my child popup. What is the command for it. If I don't botter you, could you please take a look to my code.



<SCRIPT LANGUAGE="JavaScript">
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',url=yes,scrollbars=no,resizable=no'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// End -->
</script>

This go into the body:

<a href="tellfriend.asp" onclick="NewWindow(this.href,'name','260','260','yes');return false;"><strong><font size="2" face="Arial, Helvetica, sans-serif">Send</font></strong></a>


Khalid, I will appreciate your help

Thank you

Khalid Ali
09-19-2003, 09:51 AM
//get your main window's url

var mainURL = window.location.href;

//now create child window

newWin = window.open("someURL",'');

//at this point newWin is the child window handle that you can use to communicate with it.

//now in the child window get the url

alert(top.opener.mainURL)
or set a variable in the child window

from child window

var childURL = top.opener.mainURL


//from parent window. for this to wiork you will have to make sure that child window is loaded completely

newWin.childURL = mainURL