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
Community showcase
Posted Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

1,107 views 17 14
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