|
-
Dec 12th, 2004, 03:51 PM
#1
Thread Starter
Addicted Member
How do I do a random image script?
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?
-
Dec 21st, 2004, 06:30 AM
#2
Junior Member
Re: How do I do a random image script?
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>
 Originally Posted by ddmeightball
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|