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

  • ExGuardianReader

    #2
    Re: Nested Anchors

    mlv2312@terra.c om.br wrote:
    [color=blue]
    > 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=green]
    >><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=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>
    >
    > 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?[/color]

    Why are you nesting <a> elements? Just have one after the other. They
    surely are seperate links to seperate pages?

    You can't create your own tags. You can assign tags a class (as you have
    done), then retreive all elements of a certain tag name, and filter them
    on the className attribute to arrive at just the ones you want. See the
    getElementsByTa gName() method of HTML elements.

    See http://www.w3.org/TR/DOM-Level-2-Cor...t-binding.html

    and spefically for HTML documents,


    Comment

    Working...