Scrolling while navigation in the Same page?

Hello there,

Well I have come across this problem that in big lenghty pages I am creating, I want to place a link to Go to Top or Go here/there in the same page. IT is working absolutely fine with the Anchor tags.

The problem is It just shows me the portion I am linking directly, but I want it to scroll it, i.e, it should scroll to top and also for scroll for bottom instead of showing immediately/instantly. I guess some ScrollTo functionality of Jquery will work (as searched in google).

I am very new to javascript, jquery and Confluence, so can anyone please tell me how to integrate it so that automatically while doing same page navigation, it scrolls.


2 answers

1 vote
David Simpson Community Champion Nov 08, 2011

Better than my last answer, try this as it works...

         AJS.$('html,body').animate({scrollTop: AJS.$( AJS.$(this).attr('href' )).offset().top});

Update: This works if added to the At the end of the HEAD section. I forgot to add AJS.$ to the jQuery object :(

I added this:

<script type="text/javascript">
		 $('html,body').animate({scrollTop: $( $(this).attr('href' )).offset().top});

in my Administrator -> Custom HTML -> At end of the HEAD but still it is not scrolling!

David Simpson Community Champion Nov 08, 2011

Good call. check the update above.

Added the NEW code At the end of the HEAD section. Now whats happening is, when I go to the link, and click on it, nothing is happening. should I add something more to the head section?

EDIT: It is working with Global Look and Feel theme but I am using Documentation theme.

0 vote
David Simpson Community Champion Nov 08, 2011

Try this:

By the way: Atlassian refers to their version of jQuery with AJS.$ instead of jQuery or $.

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,792 views 26 10
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