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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass originating window URL to pop-up window

Status
Not open for further replies.

cjglynn

Technical User
Joined
Apr 30, 2006
Messages
2
Location
US
I'm a JavaScript neophyte looking for some help for what seems to be a simple thing: I want to pass the URL of a Web page (say PAGE1) to a pop-up window (say PAGE2) that I will pop-up from PAGE1.

HTML code on PAGE1:
<a href="javascript:OpenPopUp(location.href)">POPUP WINDOW</a>

JavaScript Code on PAGE1:
<script language="JavaScript" type="text/javascript">
<!--
function openPopUp(value) {
var myValue=value
var myStuff = "PAGE2.htm?" + myValue
if (myValue!="") {
alert(myStuff)
window.open(mySuff, 'NAME HERE', 'width=1000,height=650,scrollbars=yes');
}
else {
alert("Please enter value.")
}
}
//-->
</script>

HTML code on PAGE2:
...
<form name='Contact' action='cgi-bin/FormMail.New.pl' method='post' autocomplete='off'>
<input type=hidden name="recipient" value="name@domain.com">
...
<script language="JavaScript" type="text/javascript">
<!--
var mystuff=getURLPram(mystuff)
document.write('<input type="hidden" name="MyURL" value=location.search.substring(1) />')
//-->
</script>
...
<input type="submit" value="Send Message" name="submit">&nbsp;<input type="reset" />
</form>

Issues:
- I can't seem to get the window.open to work on PAGE1
- Is this the right code to place on PAGE2 to get the data passed in the URL and make it part of a hidden filed in a form?

Help, please...
Thx in advance.
 
- Your window open is probably failing due to the space in your window name ("NAME HERE"). You should not use a space in a window name.

- You have called your function "openPopUp" (with a lowercase "o"), but your link is calling "OpenPopUp" (with an uppercase "O"). This will not work, as JavaScript is a case-sensitive language. You should fix one of these.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Dan: THanks for your email. With your and other suggestions, the problem is solved. Thanks again,
-- CJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top