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
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

420 views 2 13
Read article

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