Welcome visitor
* Login
* Register
It is currently May 20th, 2019, 6:35 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  change images each 5 seconds
PostPosted: August 26th, 2009, 5:29 pm 

Posts: 23
Hi, i have six images on my site that i want to change every 5 seconds, sow one at a time. do you know if this is possible for an html internet website? Tia.


Top
 Profile  
 
  Re: change images each 5 seconds
PostPosted: August 26th, 2009, 6:03 pm 
User avatar

Posts: 112
u will need something more than plain html, something like javascript. Hope this works for you:
<body onload="changePic();">
<script type="text/javascript">
var imgArray = new Array();
imgArray[0]="a.jpg";
imgArray[1]="b.jpg";
imgArray[2]="c.jpg";
imgArray[3]="d.jpg";
imgArray[4]="e.jpg";
imgArray[5]="f.jpg";
var sec=5;
var time;
var i=1;
function  changePic(){
    sec = sec - 1;
    time=setTimeout("changePic()",1000);
    if (sec==0){
        document.getElementById('imageFrame').src=imgArray[i];
        sec=5;
        if(i==imgArray.length){
            i=0;}
        else{
            i++;}
    }
}
</script>
<img id="imageFrame" src="a.jpg" />


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron