Forum Moderators: open

Message Too Old, No Replies

Anchors in IE using the id attribute

Am I missing something obvious?

         

encyclo

2:10 pm on Oct 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, here's the test page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head><title></title></head>

<body [b]id="top"[/b]>

<p><a href="#section">Link to section</a></p>

<p>lots of text...</p>

<h3 id="section">Section</h3>

<p>lots of text...</p>

<p>[b]<a href="#top">Top of page</a>[/b]</p>

</body></html>

I've got an IE6 bug that I can't seem to reproduce in a test environment. The above test page works just fine: click on the link to section, and the browser scrolls down to the appropriate anchor as definied by the

id
attribute. Click on the "Top of page" link, and the page jumps back to the top, as defined by the
id="top"
on the
<body>
tag. All well and good.

Except that on one site I have, the link to the top of page just doesn't work in IE6. The markup is identical, the page validates 100% HTML 4.01 Strict, but when you click the link, nothing happens. Works just fine in Firefox and Opera.

Is anyone aware of some obscure IE bug which would explain such behaviour? As the "real" pages use CSS-P extensively (absolute positioning, but with no positioning rules on the

body
element), could that have an influence?

Thanks in advance for your help.

photon

3:32 pm on Oct 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't know about the bug, but have you tried

<a href="#">

to see if it works?

Phantom

12:04 am on Oct 27, 2004 (gmt 0)

10+ Year Member



that wouldn't work; the href tag is for turning an anchor into a link to another page, the id tag is for using the anchor as a marker for other links with a URL like index.html#foo I'm assuming that the name attribute would work. My advise would be to use both id and name, since the problem is probaly due to inadequete support of the the id attribute.

encyclo

12:15 am on Oct 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for your input, photon:
<a href="#">
works in the particular case described, but it does not entirely solve my problem beacuse on some pages the referenced id is not at the top of the page, but lower.

Phantom: as for browser support, IE6 usually supports this just fine - and in my test case, it works very well. This is the first time I've seen IE have problems with using just an id instead of the name attribute.

It appears that IE6 is having trouble referencing id attributes outside of an absolutely-positioned block when the referencing link is within the positioned block. I still haven't isolated the exact cause, but I've got a very strong correlation between the CSS positioning and the bug.

I'll continue breaking down the page with the bug until I find the precise cause, but in the meantime, if anyone else is aware of a known IE bug which might correspond to this situation, I'd be interested.