Is it possible to load a attached file via javascript?

		<script src=""></script>
			<script type="text/javascript">
			$ (document).ready(function() {
				 $.get("hello.txt", function(msg) {
					var textArray = msg.split("\n");
			var zufall = Math.round ( ( textArray.length - 1 ) * ( Math.random() ) );

			$('body').append('<p>' + textArray[zufall] + '</p>');

this piece of code is a random generator!

if I use it on a normal html-page, it works fine, but is it possible to use it on a confluence page within the html-macro?

"hello.txt" is an attached file.

1 answer

1 accepted

I found a different solution for it:

I've got a page, that looks like this:


<script type="text/javascript">
var text = new Array(
	"hier steht dein erster text.",
	"text no. 2",
	"text no. 3",
var zufall = Math.round ( ( text.length - 1 ) * ( Math.random() ) );
document.write('<p>' + text[zufall] + '</p>');


and now I'm using this page via the include-macro.

The intension was, to avoid having the array on the same page, because it will get extremly large!

Suggest an answer

Log in or Join to answer
Community showcase
Louis De Jaeger
Posted yesterday in Off-topic

Friday fun: your best joke

Hi all Lets make this Friday fun really fun and post one (or more) of your best jokes! The joke can be about an Atlassian product, or just a really fun joke you want to share! I’m not the best j...

145 views 12 3
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot