By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,105 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,105 IT Pros & Developers. It's quick & easy.

title of referring document

P: n/a
I can't seem to find any reference for grabbing the title of the referring
page, which I want to use for creating a link. i.e.
document.write ("Our thanks to <a href='"+document.referrer+"'>" +referring
page title +"<a>"). I have looked into using location.history also. This is
probably a standard thing, but through all the forums and searches I only
find a mishmosh of things referring to using frames, a different scripting
language, etc. Can someone guide me on this?

Thanks,
Chris
Oct 24 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Christina wrote on 24 okt 2006 in comp.lang.javascript:
I can't seem to find any reference for grabbing the title of the
referring page, which I want to use for creating a link. i.e.
document.write ("Our thanks to <a href='"+document.referrer+"'>"
+referring page title +"<a>"). I have looked into using
location.history also. This is probably a standard thing, but through
all the forums and searches I only find a mishmosh of things referring
to using frames, a different scripting language, etc. Can someone
guide me on this?
That is not possible.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Oct 24 '06 #2

P: n/a
"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@194.109.133.242...
>
That is not possible.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Thanks, I was afraid of that. I have seen breadcrumb scripts using loops
and cookies that grab document titles from pages on the current site, but
had hoped there was something that could be done for this.

Is it possible to grab the title of an on-site page without using a cookie?
Some of those scripts just seem to get so complicated and people rarely
insert comments in them so I start to lose track of what each part is doing,
or why. As you can tell, I'm a novice, but I am trying to learn.

Chris
Oct 24 '06 #3

P: n/a
ASM
Evertjan. a écrit :
Christina wrote on 24 okt 2006 in comp.lang.javascript:
>I can't seem to find any reference for grabbing the title of the
referring page, which I want to use for creating a link. i.e.
document.write ("Our thanks to <a href='"+document.referrer+"'>"
+referring page title +"<a>"). I have looked into using
location.history also. This is probably a standard thing, but through
all the forums and searches I only find a mishmosh of things referring
to using frames, a different scripting language, etc. Can someone
guide me on this?

That is not possible.
to give to each link in the file the page title reference,
and alert about title of previous page seen (if it has same script)

function follow() {
var L = self.location+'';
if(L.indexOf('ref')>0) {
if(L.indexOf('#')>0) L = L.substring(0,L.indexOf('#'));
mesg = L.split('?')[1].split('&');
for(var i=0; i<mesg.length; i++) eval(mesg[i]);
alert('Thanks to have seen '+unescape(ref));
}
var ref = document.title;
var A = document.getElementsByTagName('A');
for(var i=0; i<A.length; i++) {
var H = A[i].href;
if( H && H.length>0 && (H.indexOf('#')<0 || H.indexOf('#')>1) )
{
if(H.indexOf('#')>0) { H = H.split('#'); A[i].href = H[0]; }
A[i].href += H.indexOf('?')<0? '?' : '&';
A[i].href += "ref='"+ref+"'";;
if(H.length==2) A[i].href += "#"+H[1];

}
}
}
onload = follow;

--
ASM
Oct 24 '06 #4

P: n/a
ASM
Christina a écrit :
"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@194.109.133.242...
>That is not possible.
Is it possible to grab the title of an on-site page without using a cookie?
what is not possible is to know the tltle of a page has gone away
(when new page is displayed (loaded) the previous one is no more there
to give its title)

So you have 2 methods :
- attach title of the page to each links
then you :
read location of page to extract title of previous page
- have a cookie to stock in it titles of displayed and previous pages
then
read the cookie to extract title of previous page
Some of those scripts just seem to get so complicated and people rarely
insert comments in them so I start to lose track of what each part is doing,
or why. As you can tell, I'm a novice, but I am trying to learn.
in my previous post I gave an idea to set title to each link and to get
previous page's title

without any comment ! :-(
but tested.
call for comments if necessary

You just have to copy-paste it in an external js file
and to put a call to this file in your pages (in header)

--
ASM
Oct 24 '06 #5

P: n/a
ASM said the following on 10/24/2006 6:18 PM:
Evertjan. a écrit :
>Christina wrote on 24 okt 2006 in comp.lang.javascript:
>>I can't seem to find any reference for grabbing the title of the
referring page, which I want to use for creating a link. i.e.
document.write ("Our thanks to <a href='"+document.referrer+"'>"
+referring page title +"<a>"). I have looked into using
location.history also. This is probably a standard thing, but through
all the forums and searches I only find a mishmosh of things referring
to using frames, a different scripting language, etc. Can someone
guide me on this?

That is not possible.

to give to each link in the file the page title reference,
and alert about title of previous page seen (if it has same script)
Did you test that where the referring page was from another domain? You
can't get the title of a document in a different domain using JS in a
default security environment. Your code will work with pages from within
your own site but that is as far as it can go unless you get people who
link to you to include the title of the page in the link to your page
(should be interesting to see you try to get Google to do that for you :))

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Oct 24 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.