I have 170 HTML5 animations that need to be cycled randomly when a page loads.
I figure the easiest thing to do is randomly choose the JavaScript file name for the animation.
Can someone outline easiest way of doing that?
Thanks in advance.
EDIT: I realise that maybe the language I'm using is wrong - am learning as I go.
What I want to do is set the SRC attribute in a SCRIPT tag randomly from a list of 170 filenames.
So far, I've gleaned that it should be something like this,
<!--[if !IE]>--><script id="animation" src="" type="text/javascript">
</script> <!--<![endif]-->
<script type="text/javascript">
//Files
var filesArray = ['file1.js', 'file2.js'];
//src vars
var url = 'http://www.example.com/';
// Shuffle
var file = musicArray[Math.floor(Math.random() * myArray.length)];
//Set src
getElementById("animation").src = url + file;
</script>
But that's not working for me. Is it even possible to set the SRC attribute in this way?