HTML macro with javascript

Антон Ромичев
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!
August 16, 2018

I want to add some javascript functionality to confluence pages. For example https://stiltsoft.com/blog/2015/08/confluence-tips-and-tricks-task-lists-and-automatic-calculation/ here. But I dont understand how to make my js script to be executed. Maybe there are some restrictions in confluence. 

I've added js just in the end of page in HTML MACRO

1 answer

0 votes
jndeverteuil
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.
August 16, 2018

Hello,

I'm not sure that it will help you, but on my side it works with the HTML macro on Confluence 6.10.1 with the following script :

<ac:structured-macro ac:name="html">
    <ac:plain-text-body><span id="how-many-checked"></span>
        <script type="text/javascript">
            AJS.toInit(function() {
                var count = AJS.$('li.checked').length;
                if (count == 1) {
                    AJS.$("#how-many-checked").text(count + " players.");
                } else {
                    AJS.$("#how-many-checked").text(count + " players.");
                }
            });
        </script>
    </ac:plain-text-body>
</ac:structured-macro>

I removed the CDATA section as I didn't see why I needed it from the example.

Then, it works as intended by the author :

     2018-08-17 00_35_28-Maison Home - Maison - Confluence.png

 

Maybe you can try the same?

Good luck :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events