View Full Version : send current URL through window.open

03-16-2005, 10:01 PM
hello all,

my situation:

on my main page i have a link, using window.open to popup a small page in which i have several forms for emailing the "current page" to a friend. The only problem is that the script i am using on that popup uses window.location for determining the current page. Obviously the "current page" seen by window.location is going to be the URL for the popup, not the parent page, which i wanted. can i set a variable on the main page to that URL (using window.location), and then pass it to the new window to be used by my scripts there? how? any other ideas?

here is the generic script for emailing the "current" page to a friend, which is in my popup window generated from window.open:

function initMail(form) {
text = "Check out this page: " + window.location;
form.message.value = "Hi " + form.sendto.value + " (" + form.to.value + "):\n\n"
+ text + "\n\nYour Friend,\n" + form.sendername.value + "(" + form.senderemail.value + ")";
return (form.to.value != "");

hopefully this was clear enough.

thank you! :thumbsup:

03-17-2005, 04:04 AM
You can access the parent window by using the opener object.
opener.location.href gives you the url of the opener window.