Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    anchor tag not working in IE

    Should be simple. Ha, should be! This works in everything (Mac and PC, Safari and Firefox) but not IE. I've got a simple "back to top" link at the bottom of my page to bring you back to an anchor tag at the top of the page.

    I've got

    <a id="top"></a>

    at the top of the page, and

    <a href="#top">back to top</a>

    at the bottom.

    You can see the problem at http://www.poddesign.com/myvu2/index.html?category=5

    Only tricky thing is that this is within a frameset. Does the anchor tag not work in IE in a frame? Also, I used to have <a name="top"> but was told that name was depracated in favor of id.

    Thanks,
    sigmundquirrel

  • #2
    New Coder TripperTreats's Avatar
    Join Date
    Oct 2006
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually I think the whole id/name issue is your problem in IE.

    http://www.w3.org/TR/html401/struct/links.html

    Try changing it back to having a name attribute, and I think it will work.
    Psychedelic digital art at www.trippertreats.com.

    "And in the end, the love you take
    is equal to the love you make
    ."

  • #3
    Regular Coder
    Join Date
    Aug 2005
    Posts
    364
    Thanks
    7
    Thanked 1 Time in 1 Post
    Give a TARGET attribute in anchor tag.

  • #4
    New Coder
    Join Date
    Dec 2006
    Location
    Bahrain
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts
    link for "a name"
    Code:
    <a name="#top">
    Link for back to top:
    Code:
    <a href="#top">
    #top and top are different so it doesn't match it...
    ALWAYS remember to validate your code

  • #5
    New Coder
    Join Date
    Dec 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks everyone!

    This link from TripperTreats to the W3C site had the answer:

    http://www.w3.org/TR/html401/struct/links.html

    It turns out that although all browsers SHOULD be able to find an anchor tag like <a name="top"></a>, some (meaning IE) can't find it if it's empty like that (no character content between the tags).

    So I changed it to <a name="top>&nbsp;</a> with a non-breaking space between the tags, and it's working now. BTW, "name" and "id" are both valid...

    thanks,
    sigmundsquirrel

  • #6
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,274
    Thanks
    28
    Thanked 271 Times in 265 Posts
    Quote Originally Posted by sigmundsquirrel View Post
    It turns out that although all browsers SHOULD be able to find an anchor tag like <a name="top"></a>, some (meaning IE) can't find it if it's empty like that (no character content between the tags).
    In such cases, it should be fairly obvious that you donít need the anchor element at all. Why not just put an ID on the body tag or some other tag at the top of your document and reference that?

    Quote Originally Posted by sigmundsquirrel View Post
    So I changed it to <a name="top>&nbsp;</a> with a non-breaking space between the tags, and it's working now. BTW, "name" and "id" are both valid...
    Theyíre both valid in general, but the name attribute has been deprecated on the anchor element in XHTML 1.1. In general, the ID attribute should be used unless some functionality only available to names is needed; in those cases itís good practice to use both.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •