/ Published in: JavaScript

A nice little code snippet for displaying images randomly when a page is reloaded.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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]; }
Comments
