I have a .js file that I need to reference for some code I am writing. I am currently testing on a page with the HTML Macro. I have uploaded my js file to my server in the following location:
/opt/atlassian/confluence/confluence/includes/js
In my HTML Macro, I type the following:
<script type="text/javascript" src="/confluence/includes/js/test.js"></script>
When I load my page, I see error 404 regarding my js file. It seems to be prepending "https://<confluence domain>.com/confluence/includes/js" (which I'm wondering if that's part of the problem somehow). I was able to find a CDN that hosted this particular .js file I am trying to use and when I point my HTML Macro there, everything in my code works as expected. So, the only problem I have now is the reference to my local file on the server. It really shouldn't be this difficult to work with a CMS .
I was referred here by Confluence Support since this is out of scope for their Support. They claim it "works" for them just fine but I continue to have problems on my own instance of Confluence using the exact same code that "works" for them. Hopefully someone here has seen this same issue and can direct me to a solution.
Thanks in advance!
Community moderators have prevented the ability to post new answers.
After reviewing all the paths I have tried, I realized I failed to add the ' / ' character before 'includes'. That is now working.
FYI, if you upgrade confluence you will have to copy that .js file back to the includes directory as the upgrade will remove it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not really developing a plugin, though. According to this Confluence article, I should be able to call any js file on my Confluence server (both in Custom HTML and the HTML Macro). That is not working. If I'm understanding your answer correctly, you are indicating that I need to create a plugin before I can reference the above article - is that correct? If so, the article does not specify this at all as being a prerequisite.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok I see. I would try to remove confluence from the path; It worked for me in some other cases. I think I is related to finding the correct base url or contextpath https://developer.atlassian.com/confdev/development-resources/confluence-developer-faq/how-do-i-get-the-base-url-and-contextpath-of-a-confluence-installation Hope It helps, Nelson
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I will try that. I did already try omitting 'confluence' and just start with 'includes' but that didn't work. Maybe I need to go the other direction. I will keep at it! Thanks for your input so far!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dustin,
You need to create a web resource module.
Regards
Nelson
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.