How to call a javascript from every page of a confluence space

There is a solution to call a javascript from one confluence page with the HTML macro.

There is a solution to call a javascript from all the pages of a confluence server thanks to the custom HTML which to configure from confluence administration.

Is there any solution to call a javascript from all the pages of one and only one confluence space?

1 answer

2 votes

Just have a condition in the javascript to check the current space?

AJS.params.spaceKey will get you the space key.

@Jobin, true I thought about this solution too. Is there any other way so a space admin can do this without involving a confluence admin?

Nothing that I can think of :)

Davin Studer Community Champion Sep 10, 2015

You could add the code in the page decorator to check the space key using velocity. If it is the space you want then insert the javascript.

Davin Studer Community Champion Sep 10, 2015

The upside of this approach is that the javascript is not even served if it is not the correct space as the velocity code is rendered server side.

Interresting approach. Hopefully I have a little experience with velocity and decorator files which can execute a user macro which contains the javascript.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

866 views 23 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