I'm not positive, but I don't think you can put linebreaks in an array declaration unless you use the literal notation. I also made a couple changes....
Code:
<script>
function doPreload() {
var imgRoot = "/images/";
var the_images = [
'pd2.gif',
'explore2.gif',
'games2.gif',
'shops2.gif',
'chat2.gif',
'mail2.gif',
'help2.gif',
'login2.gif',
'logout2.gif'
];
preloadImages(the_images, imgRoot);
}
function preloadImages(arrImages, root) {
for(var i = 0; i < arrImages.length; i++) {
var img = new Image();
img.src = root + arrImages[i];
}
}
</script>
Using shorter variable names whenever possible is a good idea with JS. And, concatenating the root to each images at the time of src assignment saves variable space in the array, not to mention the time you spend re-typing or copy/pasting
Bookmarks