468,119 Members | 1,690 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,119 developers. It's quick & easy.

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');"
<a name="LPHit1"/><font style='color:blue; background-color:yellow;'>SOME</font>TH<a name="LPHit2"/><font
style='color:blue; 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.anchors.

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');"<b name="LPHit1"/><font style='color:blue;

background-color:yellow;'>SOME</font>TH<b name="LPHit2"/><font
style='color:blue; 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.banchors;

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

Jul 23 '05 #1
1 1824
ml*****@terra.com.br wrote:
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');"
<a name="LPHit1"/><font style='color:blue;


background-color:yellow;'>SOME</font>TH<a name="LPHit2"/><font
style='color:blue; 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.anchors.

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');"
<b name="LPHit1"/><font style='color:blue;


background-color:yellow;'>SOME</font>TH<b name="LPHit2"/><font
style='color:blue; 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.banchors;

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


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
getElementsByTagName() method of HTML elements.

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

and spefically for HTML documents,
http://www.w3.org/TR/DOM-Level-2-HTM...t-binding.html

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Ben Wilson | last post: by
2 posts views Thread by mlv2312 | last post: by
2 posts views Thread by learner | last post: by
21 posts views Thread by adrian suri | last post: by
12 posts views Thread by Rich | last post: by
3 posts views Thread by windandwaves | last post: by
13 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.