Ever visit a web page that has a different picture every time that you visit or click the refresh button? It's a pretty simple trick to accomplish with a little bit of Javascript.
Create a web page that contains a randomly generated image.
<script language="javascript">
document.write("<img src = randomImages/pic" + Math.ceil (Math.random() * 9) + ".jpg>")
</script>
This script does a few things. The "document.write" part actually generates the "img src" code for you at the spot in the html markup specified. The "Math.ceil (Math.random()*9)" function generates a random number from 1-9. It then combines the name of the picture file ("pic"), with the random number, and the "jpg" extension. So it will write a URL to "pic1.jpg" or "pic2.jpg" or "pic3.jpg," etc. Pretty slick, huh?
<meta http-equiv="refresh" content="3" />
This will cause the pictures to update every 3 seconds (or whatever amount you set). Note that this can get really annoying and there are better ways of doing this (like with Flash). Save this version with a different name like "refreshRandom.html"
4 pts |
Went well above and beyond and created something special. |
3 pts |
Went above and beyond requirements (customized the page; used your own images, etc.). |
2 pts |
Did what was required. |
1 pts |
Missing one or more required elements or contains one or more errors. |
0 pts |
Poor showing; mostly incomplete or full of errors. |