Can't jump to Anchor in Expand macro

I've got a page with several Expand macros on it.

Below these on the page (and not within the Expand macro) are sets of data that contain links to headings within the Expand macro. The headings have the Anchor macro.

If you click on the link that goes to one of the headings within the Expand macro, and it is NOT already expanded, then the link doesn't work.

If you expand the area you want to jump to first, then click on the link, you jump to the appropriate heading.

 

I hope that makes sense. smile

Is this expected behaviour or a bug?

I'm running Confluence Server, 5.4.1.

Cheers.

1 answer

1 accepted

2 votes
Stephen Deutsch Community Champion Mar 17, 2016

This is a known issue:

https://jira.atlassian.com/browse/CONF-27357

However, if you look in the comments of the ticket, I wrote a workaround where you can add some Javascript to your Confluence instance that will enable this.  If you copy everything except the first line into your custom HTML, then it should work on all your pages.

Stephen, that's great, thank you.

This work-around used to work great for me, but now that my company has upgraded to 6.0.7, none of my links work any longer.  Any suggestions?

Stephen Deutsch Community Champion Jun 09, 2017

strange, I tested it on Confluence Cloud, which should be the latest version, and it worked OK... Might something else have changed during the upgrade?

Guys, I a newbie to such things. Where do you need to copy the macro in Confluence cloud?

Stephen Deutsch Community Champion Feb 07, 2018

Hi Jeff,

unfortunately it will currently not work for all users in Confluence Cloud, as there are restrictions as to what you can do especially when it comes to custom HTML/Javascript. You could install a browser extension such as Greasemonkey/Tampermonkey and package it as a user script, but it would only work for those users with the user script and browser plugin activated.

Thanks so much, Stephen. Your code works beautifully! I have one minor niggle though for which I haven't been able to figure out a workaround...

To make your expand trick work for a given targeted text block in an Expand macro, the Anchor macro for that targeted text must be embedded within (not before) the Expand macro in which the text block is contained. So far, so good, yes?

However, because the Anchor macro is embedded in the Expand macro, when a user follows a link to the targeted page, the page is opened and the viewport is scrolled to the expanded content, just past the Expand macro's title string. So, the user sees the expanded content, but does not see the title string for that content, which can be disorienting.

I've been trying to find a way, using JavaScript and/or JQuery, to scroll the viewport up just one line after the page is loaded and the expanded text is opened. Any recommendations? I know it's a no-no in most cases to grab control of the input focus. All I want to do is shift the viewport up by one line. Alternatively, I suppose I could add a redundant or similar title string in the Expand text block, but that's icky from a doc standpoint.

Thanks again!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,944 views 27 12
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