473,498 Members | 891 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
2 1602


ml*****@terra.com.br wrote:

I have experienced problems when dealing with nested anchors.
No surprise:
http://www.w3.org/TR/html4/struct/links.html#h-12.2.2

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>


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.getElementsByTagName('span')
a collection of all <span> elements and check their className property.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

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:
ml*****@terra.com.br wrote:

I have experienced problems when dealing with nested anchors.
No surprise:
http://www.w3.org/TR/html4/struct/links.html#h-12.2.2

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>


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.getElementsByTagName('span')
a collection of all <span> elements and check their className property.
--

Martin Honnen
http://JavaScript.FAQTs.com/


Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2306
by: Ben Wilson | last post by:
To anyone who can help me, you have my thanks in advance. I am implementing a "301 Moved Permanently" redirect in my website due to a change of our domain names. Unfortunately, I am having a...
1
1269
by: Peter Jakobi | last post by:
Hello, I want to place two lines relative to another. The problem is, that these two lines are in different groups. Is there an possibility to set the x and y values of the second line with...
1
2013
by: mlv2312 | last post by:
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...
2
1877
by: learner | last post by:
Hi, A document has many Anchors. I want to take a particular action only if some particular anchors are clicked. I mean if some anchors are clicked, i want an alert box to pop up with ok and...
12
2511
by: seajays | last post by:
I've got my page working just as I wanted it - but when I came to validate the XHTML, using W3c's validator it failed. Essentially as far as I can see it the problem is this: 1: <div> 2: <a...
21
2427
by: adrian suri | last post by:
Hi just started to experement with styleshhets, and have defined hover a:hover { Color : red; Text-decoration : none; Border-top-width : medium; Border-right-width : medium;
12
2351
by: Rich | last post by:
Strangely, on-page anchors will work on MSIE, but not on Netscape7.2 or Firefox1.5. All anchors are numbers e.g. <a href="#21">TOPIC</a> supposed to connect down to <a name="#21>beginning of...
17
4267
by: Crimperman | last post by:
Hi, need some advice on URIs In a dynamic page (perl driven) we list a number of items presented in an hierarchical tree structure. Within that page is a form which allows you to search for...
3
16524
by: windandwaves | last post by:
does it matter if I write var anchors = document.getElementsByTagName("A"); or var anchors = document.getElementsByTagName("a"); Or is there a better way to catch both <a hrefs and <A...
0
7124
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5460
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.