Jump to content

Anchors not working in Explorer


Recommended Posts

First of all, it is horrendous HTML. I realize this is the result of using WYIWYG editor and not your fault. But you really need to clean it up and make sure that the page validates. Cleaner the HTML better the page will work. Switch to HTML view to check the code generated by editor after you create a CMS page.

 

That said, you may still be able to get the anchors working if you change as follows:

 

Currently you use the following construct:

 

<a href="#pay">Go to pay anchor</a>
.
.
.
.
<p><a name="pay"></a></p>
<p></p>
<h4>Header for pay subject</h4>

 

1- Use id attribute instead of name attribute (or both if you wish but will not validate)

2 -Include the anchor in an already existing tag instead of creating a new empty <a> element (empty elements may end up with 0,0 screen coordinates depending on other styling in force in the page. I suspect this is the reason of current problem).

3- Make anchor names (that is, ids) quite distinct (so there is no accidental name clashes)

 

thus:

 

<a href="#section-pay">Go to pay anchor</a>
.
.
.
.
<h4 id="section-pay">Header for pay subject</h4>

 

 

An alternative is (and use this alternative only if you have a good reason not to use the above solution) to add a CSS rule for all empty anchors with name attribute: display: inline-block;

So you would do:

 

<a href="#pay">Go to pay anchor</a>
.
.
.
.
<p><a name="pay" style="display:inline-block;"></a></p>
<p></p>
<h4>Header for pay subject</h4>

 

Let me know if you are still having problems after making those changes

Link to comment
Share on other sites

Thank you very much for your advice. I have made the changes you suggested and the anchors are now working in IE8. I have also taken note of your comment about the html and will work on WC3 validation.

 

Greatly appreciated!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...