Return to Snippet

Revision: 37736
at December 16, 2010 10:42 by danielwrobert


Initial Code
window.onload = choosePic;

var myPix = new Array("images/00.jpg","images/01.jpg","images/02.jpg","images/03.jpg","images/04.jpg","images/05.jpg","images/06.jpg","images/07.jpg");

function choosePic() {
	randomNum = Math.floor((Math.random() * myPix.length));
	document.getElementById("myPicture").src = myPix[randomNum];
}

Initial URL

                                

Initial Description
A nice little code snippet for displaying images randomly when a page is reloaded.

Initial Title
Displaying A Random Image

Initial Tags
javascript

Initial Language
JavaScript