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

Ben Bristow April 8, 2012

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

0 votes
Thomas Lohschmidt September 7, 2014

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
TAGS
AUG Leaders

Atlassian Community Events