Forum Moderators: open

Message Too Old, No Replies

Multiple anchors on a page with same label

How do different browsers handle this

         

runner

8:03 am on Jan 14, 2006 (gmt 0)

10+ Year Member



I'm building an app that creates a page with many anchors on it. It's likely there will be several anchors with the same label.

I don't have access to every modern web browser to test this so I'm asking the following question here:

How will a browser handle multiple anchors with the same label?

For instance if there are three anchors on a page that read < a name="2006-01-15" > and I reference the URL somewebpage#2006-01-15 will this always take me to the first occurance of this anchor name?

Robin_reala

5:54 pm on Jan 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure about anchors like this, but these days fragment identifiers generally target id attributes, which can be on anything, not just a specific anchor. Of course, id attributes must be unique so this would cause you problems.

rocknbil

7:09 pm on Jan 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



They should be unique in either case, that's the point, in fact if you have multiple identical ID's it won't validate. Why can't you make some alteration to label them 2006-01-15-a, 2006-01-15-b? I'm guessing you're doing this programmatically as those are date formats used by mysql, so a little tweak to your perl/php and you're golden.

runner

5:44 am on Jan 16, 2006 (gmt 0)

10+ Year Member



My perl script grabs a list of events out of a MySQL table and formats them into an events page.

I also have a calendar with clickable dates that take you directly to the events page to the date you clicked on.

In my old script I had logic that would check to see if there was more than one event for the same date and only print the anchor tag one time.

Now that I'm using HTML::Template to generate the page I can't put the logic in there to only print one anchor tag per date.

So... I cheated and just put one anchor tag per event. It sure cut out a lot of code.