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;
}
Thanks Bikash, fore this script.
ReplyDeleteI would recommend to use a ready made tool which allows you to upload unlimited images. Have a look at this Magento Background Images Extension by FME
This extension changes the images automatically according to the settings done by the admin.
http://avianceschool.com/
ReplyDelete