Hi,
I have a simple Javascript.
alert('hello world!');
I have saved this in a file called simple.js in
/opt/atlassian/confluence/confluence/includes/resources
My 'HTML Macro' contains:
<!doctype html>
<html>
<title>My Web Page</title>
<head>
<script src="/includes/resources/simple.js" type="text/javascript"></script>
<script>alert('hello world inline!');</script>
</head>
<body>
Random Text...<br>
<img src="/includes/resources/logo.png" height="30px">
</body>
</html>
The inline alert is presented by Confluence but the one that should come from the included Javascript simple.js is not. I am not a Javascript expert so I could be doing something stupid, but the same code on a standalone browser works fine.
Any advice or pointers as to why it might not be working would be appreciated. Note that Iogo.png displays fine...done as a sanity check to verify I had the path correct. The console debugger does not show anything obvious work either.
Regards
Alan
You can, of course, code your Javascript to only act if the URL matches your page.
Cheers. Thanks for you inputs on this.
To explain some more, the 3rd party tool produces an index.html that references a library of Javascript and css. The data is then actually stored in a .zip file that the Javascript extracts and displays through the index.html.
My hope was that I could place the library of Javascript and css in a central location untouched, place the index.html code in a HTML macro and update its references to the Javascript library to the new Confluence based location. How I would handle the .zip file of data would be a whole different question that I'd need to figure that out too! As mentioned, I don't want to edit the Javascript library if at all possible. Editing the index.html code is a trivial task, but having to edit multiple files in the library would be painful,and hopefully avoidable.
From what I can see I can get the Confluence to pick up the style sheets from the central location but not the Javascript for some reason. Hence the trivial piece of code above I am using as a test. If I can't get this to execute I've no chance with the more complete solution.
Best Regards
Alan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If that's the case, you should consider writing a Confluence plugin to consume the endpoint that you are talking about and display the output as a functionality in Confluence.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you're going to do some simple Javascript, why don't you use the Custom HTML (admin/viewcustomhtml.action) functionality in Confluence?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please correct me if I'm wrong but my understanding is that the Javascript in custom html is executed for all pages whereas I only want my Javascript executed for a single page within my Confluence environment.
In reality I am trying to embed a 3rd party HTML report that's based on Javascript into Confluence so that it lives beside several other pages on the same topic.
Regards
Alan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.