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

Olivier Crozier September 10, 2015

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
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2015

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

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

Olivier Crozier September 10, 2015

@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?

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2015

Nothing that I can think of :)

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 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.

Olivier Crozier September 14, 2015

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

Atlassian Community Events