Put the java script between head tag.Create a folder “images” and keep all the images in that folder
HTML Code
img id=”imgRotator” src=”” alt=”” height=”470″ width=”600″/
Start Script
script type=”text/javascript”
var picPaths = [‘images/pic1.jpg’,’images/pic2.jpg’,’images/pic3.jpg’,’images/pic4.jpg’];
var oPics = [];
for(i=0; i < picPaths.length; i++){
oPics[i] = new Image();
oPics[i].src = picPaths[i];
}
curPic = Math.floor(Math.random()*oPics.length);
window.onload=function(){
document.getElementById(‘imgRotator’).src = oPics[curPic].src;
}
End script