title of referring document

C

Christina

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
 
E

Evertjan.

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.
 
C

Christina

That is not possible.

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
 
A

ASM

Evertjan. a écrit :
Christina wrote on 24 okt 2006 in comp.lang.javascript:


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);
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.href;
if( H && H.length>0 && (H.indexOf('#')<0 || H.indexOf('#')>1) )
{
if(H.indexOf('#')>0) { H = H.split('#'); A.href = H[0]; }
A.href += H.indexOf('?')<0? '?' : '&';
A.href += "ref='"+ref+"'";;
if(H.length==2) A.href += "#"+H[1];

}
}
}
onload = follow;
 
A

ASM

Christina a écrit :
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)
 
R

Randy Webb

ASM said the following on 10/24/2006 6:18 PM:
Evertjan. a écrit :

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 :))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top