refer to text of url

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

    refer to text of url

    How can I access the text of an url via javascript, ie. get 'foo' (and
    send it as parameter in goto(), in example:

    <a href="javascrip t:goto([foo])">foo</a>

    Or refer to it globally?

    document.links. href.text.value ?
    this.href.text ?

    --
    Rgrds,
    L.

  • Andi B

    #2
    Re: refer to text of url

    Can you clarify what you mean by accessing the text of a URL?

    "Lars Vatland" <d20030219@yaho o.no> wrote in message
    news:shosjvsogv 0p82fonel8febm6 9avdb7n70@4ax.c om...[color=blue]
    > How can I access the text of an url via javascript, ie. get 'foo' (and
    > send it as parameter in goto(), in example:
    >
    > <a href="javascrip t:goto([foo])">foo</a>
    >
    > Or refer to it globally?
    >
    > document.links. href.text.value ?
    > this.href.text ?
    >
    > --
    > Rgrds,
    > L.
    >[/color]


    Comment

    • Lars Vatland

      #3
      Re: refer to text of url

      I want to refer to the part between <a> and </a> in an url - the text
      accompanying the url. Is it possible?


      On Sat, 16 Aug 2003 18:03:44 +0100, "Andi B"
      <andi@theblackt ower.freeserve. co.uk> wrote:
      [color=blue]
      >Can you clarify what you mean by accessing the text of a URL?
      >
      >"Lars Vatland" <d20030219@yaho o.no> wrote in message
      >news:shosjvsog v0p82fonel8febm 69avdb7n70@4ax. com...[color=green]
      >> How can I access the text of an url via javascript, ie. get 'foo' (and
      >> send it as parameter in goto(), in example:
      >>
      >> <a href="javascrip t:goto([foo])">foo</a>
      >>
      >> Or refer to it globally?
      >>
      >> document.links. href.text.value ?
      >> this.href.text ?
      >>
      >> --
      >> Rgrds,
      >> L.
      >>[/color]
      >[/color]

      Comment

      • Andi B

        #4
        Re: refer to text of url

        I dont honestly know - however, if you do as you have done in your example,
        by putting the text you want to sent as a parameter already, it should
        work - the only problem is that you do have to type the text each time.

        "Lars Vatland" <d20030219@yaho o.no> wrote in message
        news:01psjv4ct5 fs8pah70qopa8tc t1jnflv0d@4ax.c om...[color=blue]
        > I want to refer to the part between <a> and </a> in an url - the text
        > accompanying the url. Is it possible?
        >
        >
        > On Sat, 16 Aug 2003 18:03:44 +0100, "Andi B"
        > <andi@theblackt ower.freeserve. co.uk> wrote:
        >[color=green]
        > >Can you clarify what you mean by accessing the text of a URL?
        > >
        > >"Lars Vatland" <d20030219@yaho o.no> wrote in message
        > >news:shosjvsog v0p82fonel8febm 69avdb7n70@4ax. com...[color=darkred]
        > >> How can I access the text of an url via javascript, ie. get 'foo' (and
        > >> send it as parameter in goto(), in example:
        > >>
        > >> <a href="javascrip t:goto([foo])">foo</a>
        > >>
        > >> Or refer to it globally?
        > >>
        > >> document.links. href.text.value ?
        > >> this.href.text ?
        > >>
        > >> --
        > >> Rgrds,
        > >> L.
        > >>[/color]
        > >[/color]
        >[/color]


        Comment

        • Laurent Bugnion, GalaSoft

          #5
          Re: refer to text of url

          Hi,

          Lars Vatland wrote:
          [color=blue]
          > How can I access the text of an url via javascript, ie. get 'foo' (and
          > send it as parameter in goto(), in example:
          >
          > <a href="javascrip t:goto([foo])">foo</a>
          >
          > Or refer to it globally?
          >
          > document.links. href.text.value ?
          > this.href.text ?[/color]

          The text of a link should, according to the Netscape doc, be accessible with

          linkInstance.te xt;

          However, there doesn't seem to be a way to identify a link namely. Of
          course you can always use the links array, but working with indexes is
          not good programming practice, except in loops of course.

          alert( document.links[2].text );

          It seems, however, to be the only way.

          Note also that this fails in IE, which doesn't seem to recognize the
          property "text" of the Link instance (alerts "undefined" ).

          HTH,

          Laurent
          --
          Laurent Bugnion, GalaSoft
          Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
          Private/Malaysia: http://mypage.bluewin.ch/lbugnion
          Support children in Calcutta: http://www.calcutta-espoir.ch

          Comment

          • Evertjan.

            #6
            Re: refer to text of url

            Laurent Bugnion, GalaSoft wrote on 16 aug 2003 in comp.lang.javas cript:
            [color=blue]
            > Note also that this fails in IE, which doesn't seem to recognize the
            > property "text" of the Link instance (alerts "undefined" ).
            >[/color]

            IE6:

            <a href='' onclick="alert( this.innerText) ;return false">Text alert</a>

            --
            Evertjan.
            The Netherlands.
            (Please change the x'es to dots in my emailaddress)

            Comment

            • Lars Vatland

              #7
              Re: refer to text of url

              Ok, thanks, I use

              <a href='' onClick="q(this );return false">foo</a> bar<br>

              (..and if else on this.text / this.innerText) .

              Is there a shorthand for 'return false', or avoid it?


              --
              /L.

              Comment

              Working...