I've been writing custom javascript code in {html}<script></script>{html} tags on the page or another and including it, I've made User Macros and all that has worked fine but I don't want to continue that route. Instead I want to upload my .js files as attachments and include them, the best way I see is
{html}<script src="/download/attachments/123/file.js" type="text/javascript"></script>{html}
That seemed too easy and apparently was, Chrome is throwing an error when trying to load it:
Refused to execute script from 'http://confluence/download/attachments/4426187/HotFixCreation.js' because its MIME type ('application/x-upload-data') is not executable, and strict MIME type checking is enabled.
Any ideas how I can use my .js attachments?
Have you tried editing the mime type in the attachment properties?
I never clicked on properties before, it worked like a charm.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I never clicked on the properties before, worked like a charm.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
$.getScript is to include the file content in the body of the page. It's to work around the cache... it solve the shituation, but it's not a best practice.
Yes, Davin, edit the content type of the js file to "application/javascript" is a best solution!
To change the content type of an attachment, please visit the view page attachment (viewpageattachments.action) and click in Properties of the js file.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure why it's not blocked but I can load it from JavaScript:
{html} <script type="text/javascript"> $.getScript('/download/attachments/123/file.js'); </script> {html}
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.