Why doesn't the TOC macro work in IE with headings that contain punctuation?

Hello,

We have some page headings such as "Step 2: Catalog Transfer", or "How to create widgets, and deploy them".

Clicking these links in a page's TOC when using IE version 8 or 9 doesn't take one to the appropriate header.

A look at the url reveals that IE is (for example) parsing a comma in a TOC link as: &2C.

Can anyone point me to some information on why this might be happening, or what in my Confluence configuration could be causing this? Or is this simply the rule to follow: "no punctuation in headers populated in a TOC"?

Thanks!

Ben

1 answer

Hi,

I found out, too. On some pages whose title contains special characters, the toc macro links do not work.

As a workaround I wrote the following JavaScript lines, which put an anchor before every heading, which makes the toc links functional again.

Put this into your main.vmd decorator:

#if( ($mode != "edit" && $mode != "edit-preview" ))
<script type="text/javascript">
AJS.toInit(function() {
if (jQuery('.toc-macro').length > 0) {
   jQuery.each(jQuery('h1, h2, h3, h4, h5, h6'),function(index,value){
     var id = decodeURIComponent(jQuery(this).attr("id"));  
     var anchor = '<a name="'+id+'" style="font-size:0;line-height:0;height:0;width:0;position:absolute;"> </a>';
     jQuery(this).before(anchor);
   });
}
});
</script>
#end

Notice: I used "jQuery" instead of AJS.$ because AJS.$.each does not work in a Velocity decorator.

Regards

Thomas

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Tuesday in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

461 views 19 9
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you