title of referring document

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christina

    title of referring document

    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='"+documen t.referrer+"'>" +referring
    page title +"<a>"). I have looked into using location.histor y 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


  • Evertjan.

    #2
    Re: title of referring document

    Christina wrote on 24 okt 2006 in comp.lang.javas cript:
    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='"+documen t.referrer+"'>"
    +referring page title +"<a>"). I have looked into using
    location.histor y 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)

    Comment

    • Christina

      #3
      Re: title of referring document

      "Evertjan." <exjxw.hannivoo rt@interxnl.net wrote in message
      news:Xns9866E60 23DCF8eejj99@19 4.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


      Comment

      • ASM

        #4
        Re: title of referring document

        Evertjan. a écrit :
        Christina wrote on 24 okt 2006 in comp.lang.javas cript:
        >
        >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.wri te ("Our thanks to <a href='"+documen t.referrer+"'>"
        >+referring page title +"<a>"). I have looked into using
        >location.histo ry 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('r ef')>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.getEle mentsByTagName( '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

        Comment

        • ASM

          #5
          Re: title of referring document

          Christina a écrit :
          "Evertjan." <exjxw.hannivoo rt@interxnl.net wrote in message
          news:Xns9866E60 23DCF8eejj99@19 4.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

          Comment

          • Randy Webb

            #6
            Re: title of referring document

            ASM said the following on 10/24/2006 6:18 PM:
            Evertjan. a écrit :
            >Christina wrote on 24 okt 2006 in comp.lang.javas cript:
            >>
            >>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.writ e ("Our thanks to <a href='"+documen t.referrer+"'>"
            >>+referring page title +"<a>"). I have looked into using
            >>location.hist ory 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.javas cript FAQ - http://jibbering.com/faq
            Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

            Comment

            Working...