Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

342 views 23 8
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