/    Sign up×
Community /Pin to ProfileBookmark

Grab parent URL

Alright so I have a popup, and I need a javascript code that will
1) Grab the parent URL (The URL with the link to the popup)
2) Put that URL into a hidden form

Anyone know how to do this?
Thanks.

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@cridleyJul 08.2006 — hrm... popups... hidden form.... all sounds very suspiscious to me.... try

document.referrer
Copy linkTweet thisAlerts:
@klanga2049authorJul 08.2006 — yea..but the problem is I don't know any javascript -_-
Copy linkTweet thisAlerts:
@cridleyJul 08.2006 — ahhh... maybe try typing 'javascript tutorial' in google?

<form action="whatever.html" method="post">

<script language="javascript">

doument.write("<input type='hidden' name='whatever' value='".document.referrer."'>");

</script

</form>

There you go...
Copy linkTweet thisAlerts:
@klanga2049authorJul 08.2006 — well that just gives me the url of my form processor...
Copy linkTweet thisAlerts:
@codeDizzyJul 09.2006 — yup, that's what it supposed to do.

What do you want to get anyway?
Copy linkTweet thisAlerts:
@klanga2049authorJul 09.2006 — I have a popup

I need a javascript variable that is the popup's parent page.
Copy linkTweet thisAlerts:
@codeDizzyJul 09.2006 — you mean the document's href that opened the pop-up window?
Copy linkTweet thisAlerts:
@ananiasJul 09.2006 — [code=html]<html><head><title>popup demonstrator</title>
<script type='text/javascript'>
function makePopup () {
var r = "<html><head><title>Popup Window</title>n<script type='text/javascript'>n"
+ "var myParent;</scr" + "ipt></head><body>" + document.getElementById("popup").value
+ "n<br><a href='#' onmousedown='myParent.focus();return false'>Return To Parent</a></body></html>";
setTimeout(function () {
var opts = 'toolbar=yes,location=yes,directories=yes,status=yes,'
+ 'menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes';
var w = window.open('', 'Popup Window', opts);
w.document.write(r);
w.document.close();
w.myParent = window;
w.focus() }, 50);
}
</script>
</head>
<body>
<h1>The Parent Page</h1>
<p>Pressing the link creates a popup window that refers back to this one.</p>
<form action="#">
<label for="popup">Enter the HTML for the body of the popup here:</label>
<textarea id="popup" rows="15" cols="100"><h1>This is the Popup Window</h1></textarea><br>
<a href="#" onmousedown="makePopup();return false">Show Popup</a>
</form></body></html>[/code]
Copy linkTweet thisAlerts:
@ananiasJul 09.2006 — I use a macintosh, where IE is unsupported. It works fine for me in Camino, Firefox, Mozilla, Safari, and Opera. In the past I've bothered to get things to work on the mac version of IE but that did't ensure it would work on the PC version so I lost interest in JScript. Perhaps someone well versed in the differences in the two languages could point out the fix.
×

Success!

Help @klanga2049 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...