Click to See Complete Forum and Search --> : Referring URL's title?


pyro
12-22-2002, 07:17 PM
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.

swon
12-22-2002, 07:32 PM
I don't think that is possible with the document.referrer method. It will just gives you back the url from the referring page.

pyro
12-22-2002, 07:45 PM
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?

gil davis
12-22-2002, 07:56 PM
Originally posted by pyro
send the title along with the previous URL using something like this..
...
top.location.href = "sendarticle.html?test";

top.location.href = "sendarticle.html?" + escape(document.title);

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.

swon
12-22-2002, 07:56 PM
Is there any way to get the referring documents title?

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>

swon
12-22-2002, 08:03 PM
Sorry, Gil, did not see that you've already post it (same time):D

pyro
12-22-2002, 08:16 PM
Originally posted by gil davistop.location.href = "sendarticle.html?" + escape(document.title);
Thanks worked like a charm.

I was trying it close to what swon posted but I forgot my + :(

pyro
12-22-2002, 08:42 PM
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?

swon
12-22-2002, 08:50 PM
Do you have the <title>Document</title> within?

pyro
12-22-2002, 08:57 PM
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.

swon
12-22-2002, 09:07 PM
Yep, for me too :o