Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Saturday 30 December 2017

HTML program to change images

<!DOCTYPE html>
<html>
<head>
  <title>Demo</title>
</head>
<body onload="startTime();">
<img id="YOurImage1" />
<script>
var imgArray = new Array("Your Image1","YourI mage2","Your Image3");  /*Any number of sequentially connected images*/

var imgCount = 0;
function startTime() {
    if(imgCount == imgArray.length) {
        imgCount = 0;
    }
    document.getElementById("img1").src = imgArray[imgCount];
    imgCount++;
    setTimeout("startTime()",100 /*time delay(in millieconds)*/);
}
</script>
</body>
</html>

No comments:

Post a Comment