What I want it a random image script made in Javascript. It needs to change every 5 seconds with a different image. That would be a setInterval(); method, but how would I cache the images and put all this on a web page?
Printable View
What I want it a random image script made in Javascript. It needs to change every 5 seconds with a different image. That would be a setInterval(); method, but how would I cache the images and put all this on a web page?
you can test with the following code
it can be further modified by preloading images
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language = "javascript">
var i
i = 7
function f()
{
if(i > 12)
{
i = 7
}
document.getElementById("IM").src = "http://www.vbforums.com/images/icons/icon" + i + ".gif";
i++
}
</script>
</HEAD>
<BODY>
<img src = "http://www.vbforums.com/images/icons/icon12.gif" id = "IM">
<br>
<input type = "button" name = "b1" value = "Change" onClick = "f();">
</BODY>
</HTML>
Quote:
Originally Posted by ddmeightball