It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Running JS Script on Confluence Edit View

Hi,

I'm running a JS Script on Confluence adding a HTML content to modify some tables and it's working good, But I would like to run that script even when the users are editing the Confluence Page, is there a way to run the scripts on the edit view?

If yes, can you provide the documentation

Thanks

2 answers

If you apply the JS to the Custom HTML section, then it will show up on every page, regardless of whether you are in view or edit mode:

https://confluence.atlassian.com/confkb/how-to-use-javascript-in-confluence-313458839.html

Hi Stephen Deutsch,

Thanks for your answer I tried to run the script from "Custom HTML section" and I got to run the script on other views of Confluence but not on the edit view.

Any other suggestion?

I figured out how to run JavaScript only while editing a page, but it's a dirty solution I would say.

You have to edit the page layout file (page.vmd).

There you just can insert a code block like this:

#if ($mode == "edit")
<script>
DO JS STUFF
</script>
#end

 But you can't use jQuery here (I don't know why...), only pure JavaScript.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

How is your team having fun and bonding, remotely, utilizing Confluence?

Thanks everyone for answering last week’s question. The winner of the random drawing from those who commented is: @LarryBrock I’ll contact you separately with your prize details. This wee...

269 views 9 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you