The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Running JS Script on Confluence Edit View

alanhernandez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 7, 2018

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Stephen Deutsch
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 Champions.
February 7, 2018

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

alanhernandez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 8, 2018

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?

Like Irina_Bel_Stiltsoft_ likes this
0 votes
Hauke Hörhold
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 Champions.
October 7, 2019

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.

TAGS
AUG Leaders

Atlassian Community Events