Confluence hide text permamently using JavaScript


I am using JavaScript to hide some text on page, using the HTML maco. It works as expected, but I would like to make the change permanently. So one user presses the button and the text is hidden, even for other users.

I am using the following code in the HTML macro:

<div id='someTest'>
	some Text
<button type="button" id="hidden">Hide me</button>
<script type="text/javascript">
  if ( $('#someTest').css('visibility') == 'hidden' )

1 answer

0 vote

You can't do that with javascript alone.

Javascript runs on the browser, not the server. To make this work, your javascript *must* write something back into the page to save the information that something has been hidden, so that the next time the page is rendered for another user, the javascript can read it and hide it.

Also, bear in mind that hidden just means "the browser hides it". The text is all there in the page no matter what you do.

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 Friday 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...

274 views 11 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