472,783 Members | 1,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,783 software developers and data experts.

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 1573


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
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
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
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
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
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
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
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
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
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
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.