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


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"?



1 answer


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>';

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



Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

159 views 3 5
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