Customer Script in Sidebar

Christian Isaza Aguirre December 19, 2022

Hello, everyone.

 

My question would be if using JavaScript scripts on Confluence's Sidebar is supported, is it something meant to work smoothly or something like this?

 

The questions comes from one of the users using my company's Confluence spaces, he is running a JavaScript script that is retrieving information from somewhere else, but when they try to add more functions (alert, specifically) to the script it won't let them save the changes.

 

Per the documentation (although it does not say it clearly) apparently JS is not supported on Sidebar and the fact they got it running in the first place seems to be odd (they run it with the {html} tags from the html macro on Confluence).

 

So, I just would like to have a response regarding it.

Thanks in advance.

2 answers

0 votes
Christian Isaza Aguirre December 21, 2022

Hi everyone,

 

Any ideas what could this be? Thanks

0 votes
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 20, 2022

Hi @Christian Isaza Aguirre ,

welcome to the Atlassian community!

Javascript is something that works on client side and there is no limitation about where it works. So it should work also on Confluence sidebar side.

Here a guide about how to setup your javascript https://confluence.atlassian.com/confkb/how-to-use-javascript-in-confluence-313458839.html

Fabio

Christian Isaza Aguirre December 20, 2022

@Fabio Racobaldo _Herzum_  

 

Thank you so much for your response.

 

I was checking that documentation and this:
Configure the sidebar 

 

But I cannot find a solution to our issue. It seems there is a code error but we definitely cannot find where it is; myself, I am not a programmer so this is getting kind of difficult to me.

Note: The error they get when trying to save the changes to the code is:

Web Application Firewall - This transfer is blocked by a Web Application Firewall - But this only happens when changing that code specifically, anything else is not reporting such error.

More context:

As mentioned before, our team is already using a script they wrote about 5 years ago, and now they try to ad alerts not working, and this is something the person writing the code has noticed:

"I have started creating a minimal case that triggers the error. What I have found is that the code does not like "if" statements in javascript, not even when they are commented out!

So this works:
{html}<script>
alert("hello world");
var a=1;
do { a=0; alert("hello again") } while (a==1)
</script>{html}

This does not work:
{html}<script>
alert("hello world");
var a=1;
if (a==1) { a=0; alert("hello again") }
</script>{html}

and this does not work either:
{html}<script>
alert("hello world");
var a=1;
// if (a==1) { a=0; alert("hello again") }
</script>{html}"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events