Joe's Quest

Fix the bug of ANCHOR not working in IE

Broken anchor in IE ANCHOR may not work in IE when it's working fine with Firefox. Check the HTML code to see if the ANCHOR is written in this way:
  1. <div><a name="anything"></a></div>
Then it can not work in IE. Don't know why. Maybe another bug? Note that there's nothing in the ANCHOR tag. Here's how to fix it: Simply add something even a space in it. For example like this:
  1. <div><a name="anything">&nbsp;</a></div>

Discussion (21)

There are 21 responses to “Fix the bug of ANCHOR not working in IE”.

  1. Awais responded:

    · Reply

    echo ”

    “;

    see this code anchor not working not space only the whole image is loading there but anchor not working i don’t whats wrong,…reply me if you can help me will be thankful
    Awaisakhtar@yahoo.com please mail

    • Tkjune responded:

      @Awais: I wrote mail to you but the mail was rejected. Would you check if it’s correct? I cannot see the code you wrote after echo here..

  2. Agustín responded:

    · Reply

    thanks a lot! this really helped me out!

    muchas gracias! esto solucionó mi problema!

  3. Tom responded:

    · Reply

    I didn’t know about this IE problem – it came as quite a shock. I found your fix via a Google search, thanks for helping me fix my issue quickly.

    • Tkjune responded:

      @Tom Glad to be of help~

    • Bob responded:

      Nothing involving IE issues comes as any sort of a shock. I wish there was a way to quantify the number of hours I will have wasted in my life chasing down issues specific to IE. Actually, I’d prefer to wish for IE to vanish from the face of the earth, but I’d probably have better luck wishing for world peace.

      Thanks to Joe’s Quest for this solution!

  4. After many hours of trying to sort out anchor code issues between browsers especially Internet Explorer, I have managed to solve this problem. I found that to solve this problem especially when using tables or nested tables is that the anchor tag cannot be placed in a cell on its own, it has to be placed immediately before text a graphic a horizontal line etc but NOT on its own. This has worked for me across all browsers.

  5. Ali responded:

    · Reply

    thanks mate ! Works fine.

  6. Great thought!
    Keep it up

  7. Nice post.
    Well done!

  8. Paul responded:

    · Reply

    After spending a large amount of time with this and trying everyone’s different hacks with inconsistent results I added this to the bottom of my html page:

    // fix IE bug where hash anchors don’t update scrolltop on some occasions
    if (window.location.hash)
    window.location = window.location.hash;

    I had a unique requirement where I had an email with anchor links jumping to an anchor on my site.

  9. Paul responded:

    · Reply

    Within js script tags:

    if (window.location.hash)
    window.location = window.location.hash;

  10. Monique responded:

    · Reply

    On a website I built (see http://www.depeppelenbosch.nl), I have also made a top link “naar boven” which should go to the 1st . This works on all browsers except IE9 (yes, IE 8 and 7 work well).
    What happens in IE9 is that you see the page first goes up to the top, but then in a split second the browsers goes to the top of the HOME-page. So it doesn’t work for all subpages op the site.
    This seems a very strange problem to me… ;-(
    Does someone know how to solve that?
    Thanks in advance!!

  11. Monique responded:

    · Reply

    In the 2nd line you should read: …go to the 1st div which is div id=”website”.

  12. Gary responded:

    · Reply

    @John – we don’t have a lot of clients that use this, but we had one and they were putting the anchor tags in a blank cell in a table (yes, it’s an older website) and it wouldn’t work on IE. So, first we used the original solution posted by @Tkjune, but the CMS they are using uses tinymce and tinymce was “cleaning up” after them and removing the “unneeded” spaces.

    When I saw your reply, I put that into practice and the problem has disappeared. Thanks for sharing the research on this one to both of you.

    • Tkjune responded:

      @Gary, Generally, CMS’ mce filters ” “, that’s why I used ” “. Obviously you met a more strict one 🙂

  13. Peter Cunningham responded:

    · Reply

    Thank you so much for this advice – it worked perfectly

Leave a Comment

Your email address will not be published. Required fields are bold.