nested anchors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mlv2312@terra.com.br

    nested anchors

    Hi,

    I have experienced problems when dealing with nested anchors.

    I implemented some code to perform highlighting and specific anchors
    are used for the searched words. The problem is when the searched words
    are inside <a href> tags, the links are lost after putting my anchors.
    For example:

    <a class="Programa " href="#" OnClick="window .open('/something.tif') ;"[color=blue]
    ><a name="LPHit1"/><font style='color:bl ue;[/color]
    background-color:yellow;'> SOME</font>TH<a name="LPHit2"/><font
    style='color:bl ue; background-color:yellow;'> ING</font></a>

    Anchors 'LPHit' are used to navigate between the searched words inside
    the html page. The list of anchors 'LPHitXXX' are recovered by calling
    the document.anchor s.

    I wouldn´t like to change my algorithm too much, so I was wondering
    if it is possible to create another kind of tag, for example 'b' and
    replace the above as following:

    <a class="Programa " href="#" OnClick="window .open('/something.tif') ;"[color=blue]
    ><b name="LPHit1"/><font style='color:bl ue;[/color]
    background-color:yellow;'> SOME</font>TH<b name="LPHit2"/><font
    style='color:bl ue; background-color:yellow;'> ING</font></a>

    And I need to be able to get the list of 'b' anchors 'LPHitXXX', by
    calling some custom method: document.bancho rs;

    Is it possible? Or else is there another idea to deal with nested
    anchors?


    Best regards

  • Martin Honnen

    #2
    Re: nested anchors



    mlv2312@terra.c om.br wrote:

    [color=blue]
    > I have experienced problems when dealing with nested anchors.[/color]

    No surprise:


    [color=blue]
    > I wouldn´t like to change my algorithm too much, so I was wondering
    > if it is possible to create another kind of tag, for example 'b' and
    > replace the above as following:
    >
    > <a class="Programa " href="#" OnClick="window .open('/something.tif') ;"
    >[color=green]
    >><b name="LPHit1"/><font style='color:bl ue;[/color]
    >
    > background-color:yellow;'> SOME</font>TH<b name="LPHit2"/><font
    > style='color:bl ue; background-color:yellow;'> ING</font></a>[/color]

    It is usually not a good idea to create tags on your own and use them in
    HTML, and b is already defined in HTML
    <http://www.w3.org/TR/html4/present/graphics.html#h-15.2.1>
    so it has a predefined meaning.
    If you want a generic element you can use span then put some class
    attribute on it e.g.
    <span class="LPHit1"> </span>
    You can then script
    document.getEle mentsByTagName( 'span')
    a collection of all <span> elements and check their className property.

    --

    Martin Honnen

    Comment

    • mlv2312@terra.com.br

      #3
      Re: nested anchors


      Thanks Martin,

      your idea worked fine! However I needed to use another tag, 'hidden',
      instead of using the 'span' tag. The 'span' tag brought me some
      problems and I decided to use another one.

      Best regards!


      Martin Honnen wrote:[color=blue]
      > mlv2312@terra.c om.br wrote:
      >
      >[color=green]
      > > I have experienced problems when dealing with nested anchors.[/color]
      >
      > No surprise:
      > http://www.w3.org/TR/html4/struct/links.html#h-12.2.2
      >
      >[color=green]
      > > I wouldn´t like to change my algorithm too much, so I was[/color][/color]
      wondering[color=blue][color=green]
      > > if it is possible to create another kind of tag, for example 'b'[/color][/color]
      and[color=blue][color=green]
      > > replace the above as following:
      > >
      > > <a class="Programa " href="#"[/color][/color]
      OnClick="window .open('/something.tif') ;"[color=blue][color=green]
      > >[color=darkred]
      > >><b name="LPHit1"/><font style='color:bl ue;[/color]
      > >
      > > background-color:yellow;'> SOME</font>TH<b name="LPHit2"/><font
      > > style='color:bl ue; background-color:yellow;'> ING</font></a>[/color]
      >
      > It is usually not a good idea to create tags on your own and use them[/color]
      in[color=blue]
      > HTML, and b is already defined in HTML
      > <http://www.w3.org/TR/html4/present/graphics.html#h-15.2.1>
      > so it has a predefined meaning.
      > If you want a generic element you can use span then put some class
      > attribute on it e.g.
      > <span class="LPHit1"> </span>
      > You can then script
      > document.getEle mentsByTagName( 'span')
      > a collection of all <span> elements and check their className[/color]
      property.[color=blue]
      >
      > --
      >
      > Martin Honnen
      > http://JavaScript.FAQTs.com/[/color]

      Comment

      Working...