// JavaScript to interpolate random images into a page. // Steps to add new image // =========== // 1. change the number of images // =========== var ic = 2; // Number of alternative images //== no need to change var pic1 = new Array(ic); // Array to hold filenames picurl = "/docs/IO/10241/"; // Picture URL, in this case, it is the same as the support file location // ============ // 2. copy the following line: // pic1[#] = "photo_1.jpg"; // and then paste it at the bottom of the image list. Remember to change # to the correct number // ============ pic1[0] = "photo_1.jpg"; pic1[1] = "photo_2.jpg"; function pickRandom(range) { if (Math.random) return Math.round(Math.random() * (range-1)); else { var now = new Date(); return (now.getTime() / 1000) % range; } } // Write out an IMG tag, using a randomly-chosen image name. var choice1 = pickRandom(ic); document.writeln('');