My example code had a small error in it which was not fatal but, I have corrected it in the previous post anyway. Also, javascript is required for this to work, I am adding a bit that will give non-javascript enabled browsers something to display. Using what you have, you could adapt it like so:
Code:
<div id="logoName">
<script type="text/javascript">
var logo=["images/logo.gif", "images/logo2.gif", "images/logo3.gif", "images/logo4.gif"]
logo.sort(function() {return 0.5 - Math.random();})
document.write('<img src="'+logo[0]+'" alt="logo name" width="220" height="90">')
</script>
<noscript><img src="images/logo.gif" alt="logo name" width="220" height="90"></noscript>
</div>
You just need to have the images mentioned for the variable logo in the images directory. You can use less:
Code:
var logo=["images/logo.gif", "images/logo2.gif"]
or more:
Code:
var logo=["images/logo.gif", "images/logo2.gif", "images/logo3.gif", "images/logo4.gif", "images/logo5.gif"]
Four is a good minimum number, if you want some variability. Remember though, this is random, so the same one can come up repeatedly.
Bookmarks