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