Add Changing Images to Magento Home Page

Found this code that uses javascript to change images on your home page in Magento Commerce.

Simply edit your home landing CMS Page and add this code. You’ll have to change the names of the files below and add the complete URL of where you want to be taken when clicking a particular image.

<!–Image Slider Start–> <div align=”center”> <script type=”text/javascript”> var image1=new Image() image1.src=”{{skin url=images/work-truck-equipment.jpg}}” var image2=new Image() image2.src=”{{skin url=images/banner_2.jpg}}” var image3=new Image() image3.src=”{{skin url=images/banner_3.jpg}}” </script> <a href=”http://##”> <img src=”{{skin url=images/work-truck-equipment.jpg}}” border=”2″ name=”slide” width=”890″ height=”277″ /></a> <script> //variable that will increment through the images var step=1 function slideit(){ //if browser does not support the image object, exit. if (!document.images) return document.images.slide.src=eval(”image”+step+”.src”) if (step<3) step++ else step=1 //call function “slideit()” every 2.5 seconds setTimeout(”slideit()”,5000) } slideit() </script> </div> <!–Image Slider End–>

You must be logged in to post a comment.