Calling a .js file from within the HTML macro

Evening,

I've got some HTML/java that runs a conversion process (you add in the HTML colour values and it shows an example plus converts the code to Hex etc). This is on a Confluence page inside the HTML macro.

Although the entire page is rendered, it doesn't function, so no conversions or examples. The reason for this is the macro strips out the javascript.

So, I've created a .js file and have changed part of the HTML to call the .js file.

I've tried calling it from both the page itself (having added it as an attachment) and also from my PC. Neither work.

The code I've changed used to look like this:

  • <link rel="stylesheet" href="../stylesheet-1-simple.css">

but now looks like this:

So, can anyone see what I am doing wrong?

Thanks in advance for your help. :)

2 answers

The tags for this are:

js, htmlmacro, javascript, java

But for some reason Answers wouldn't let me add these...

It's really too late but you can do it like that :

 In your atlassian-plugin.XML you have to download it as a resource:

<web-resource key="web-resources-id">
    <resource type="download" name="file-name" location="/path/file.js"/>
 <context>Group-id</context>  
</web-resource>

Then in your HTML file you can Access it using its new path:

<script src="confluence-base-url/download/resources/group-id.artifact-id:web-resources-id/file-name"/>

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 3 hours ago in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

56 views 4 4
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you