Hi,
Does anyone know how you can include an externally hosted javascript file from a user macro?
I am finding that the <script> tag completely kills the user macro.
All I want to be able to do is include a standalone javascript file like:
<script type="text/javascript" src="/some/directory/someFile.js">
Any help or suggestions would be greatly appreciated.
Community moderators have prevented the ability to post new answers.
Found the answer!!
User macros die when you do something as follows:
<script type="text/javascript" src="src.js"></script>
If you include the script tags with a newline before the start and end it fixes it, example:
<script type="text/javascript" src="src.js">
</script>
Hope this helps!
THAT'S THE SOLUTION!
If only Atlassian support could have told me that.
Looks like a strange bug in version 4.0. Previous versions didn't have this issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry to resurrect an old thread but I'm having a similar issue and this doesn't work for me.
When I put some JS between two <script> tags it gets mangled with some "//<![CDATA[" tags (even when I put in an extra line as you suggest. Does the above solution still work for you? (I'm trying to implement a Twitter feed and the Widget Connector's not working.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Probably only of limited use, but scripted user macros from ScriptRunner for Confluence have no such issues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
you can append the needed Javascript and css via the Global Administration -> Custom HTML -> "At the end of the BODY".
I know with this way you split your usermacro code apart but it works. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would only want the javascript file to be loaded when the macro is inserted on a page. Thanks though.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The correct way is to register your javascript in you atlassian-plugin.xml file as resource and "inlcude" this resource in your velocity file.
Atlassian Documenation:Including Javascript and CSS resources
This is the way, I do it every time ;-)
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.
Oh now I read, that you wrote an user macro, than my answer doesn't fir your needs, sorry
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much Ryan, your solution worked for me too, on Confluence 4.2.8.
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.
Yes, the script include does appear to work because the javascript file is loaded, but then the rest of the macro fails after that point. I have even tested including a blank javascript file and that also broke the macro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am having issues with this as well. I had a ticket open but Atlassian said as it's custom they cannot provide support.
It appears to break all content after the <script> tags.
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.