/    Sign up×
Community /Pin to ProfileBookmark

Referring URL’s title?

Anyone know how I can get the referring pages title? I can get the url with document.referrer, but don’t know how I can get the title.

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@swonDec 23.2002 — I don't think that is possible with the document.referrer method. It will just gives you back the url from the referring page.
Copy linkTweet thisAlerts:
@pyroauthorDec 23.2002 — Is there any way to get the referring documents title? Or, I thought of another way, can I can send the title along with the previous URL using something like this..

<head>

<script language=JavaScript>

function open()

{

top.location.href = "sendarticle.html?test"

}

</script>

</head>

<body>

<A HREF="javascript:open()">Send</A>

</body>

That will send test along with the URL, but how do I send the document.title?
Copy linkTweet thisAlerts:
@gil_davisDec 23.2002 — [i]Originally posted by pyro [/i]

[B]send the title along with the previous URL using something like this..

...

top.location.href = "sendarticle.html?test";

[/B]
[/QUOTE]

[font=courier]top.location.href = "sendarticle.html?" + escape(document.title);[/font]

I used the escape method so that the server won't get confused in case there are spaces in the title. On the receiving end, use "unescape()" to decode it.
Copy linkTweet thisAlerts:
@swonDec 23.2002 — [B]Is there any way to get the referring documents title?[/B]

Yes, use this one:

<head>

<script language=JavaScript>

function open()

{

title = document.title;

top.location.href = "sendarticle.html?title="+ title;

}

</script>

</head>

<body>

<A HREF="javascript: open()">Send</A>

</body>
Copy linkTweet thisAlerts:
@swonDec 23.2002 — Sorry, Gil, did not see that you've already post it (same time)?
Copy linkTweet thisAlerts:
@pyroauthorDec 23.2002 — [i]Originally posted by gil davis[/i]top.location.href = "sendarticle.html?" + escape(document.title);[/QUOTE]
Thanks worked like a charm.

I was trying it close to what swon posted but I forgot my + ?
Copy linkTweet thisAlerts:
@pyroauthorDec 23.2002 — Well, I thought it was working...

It appears that using gil's method, when I go to read it on the other page, it uses the other pages title. Also, now I can't get it to work the other way anymore. ?

<html>

<head>

<script language=JavaScript>

function open()

{

top.location.href = "sendarticle.html?" +document.title+ "test";

}

</script>

</head>

<body>

<A HREF="javascript: open()">Send</A>

</body>

</html>

That will send me to the URL with test after the ?. So, for some reason it isn't reading the JavaScript. Any ideas?
Copy linkTweet thisAlerts:
@swonDec 23.2002 — Do you have the <title>Document</title> within?
Copy linkTweet thisAlerts:
@pyroauthorDec 23.2002 — Nope I didn't even have a title. It must be time for bed. I guess that's what happens after stairing at a computer sceen for 12 hours. Thanks swon.
Copy linkTweet thisAlerts:
@swonDec 23.2002 — Yep, for me too :o
×

Success!

Help @pyro 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...