Aug 7, 2012

f Comment

[SOLVED] Anchor Tag Not Working In Internet Explorer!

Amazon Recently I found this issue in Internet Explorer 8 but it may apply to other Internet Explorer versions as well. I've tested on other modern browsers including Firefox and Google Chrome and they don't have this issue.

Problem
I have the following link at the top of a post:

<a href="#comment-form">Leave a Comment</a>
which when clicked is supposed to go to the comment form at the bottom. Here's the HTML for the anchor 'comment-form':

<a name='comment-form'/>
Comment Form:
[... HTML for a form for guests to leave comments ...]

In HTML you can create anchors like this so that you can allow users to jump to different places on the same webpage. This works perfectly in every browser except IE8.

Solution
Modify the following:

<a name='comment-form'/>
Comment Form:
[... HTML for a form for guests to leave comments ...]

To

<a name='comment-form'>Comment Form:</a>
[... HTML for a form for guests to leave comments ...]

so that there's some text between <a> and </a>. This fix will work in Internet Explorer 8 and every other browser!

Basically the rule of thumb is the anchor CANNOT be empty and MUST enclose some text. If you break this rule then it may or may not work depending on your browsers.

On the other hand, as of 12/3/2011, <a name='comment-form'></a> works in the latest version of Firefox and Chrome and Internet Explorer.
Again <a name='comment-form'/> will work in the latest version of Firefox and Chrome but NOT Internet Explorer as of 12/3/2011.

The conclusion is always try to enclose some text in the anchor tag so that it will ALWAYS work in EVERY browser!
If you have any questions let me know and I will do my best to help you!
Please leave a comment here!
One Minute Information - by Michael Wen
ADVERTISING WITH US - Direct your advertising requests to Michael