Random Images

Last updated: 08.05.2002

This is a poor man's random image script. The traditional method for doing this has been to use a server-side Perl or shell script. If you can count on your users having (and using) JavaScript, then this is a pretty good alternative. It simply stores a list of image pathnames and, when the page is being built up, writes an instruction to display one of them, chosen at random.

If you use this script in a real application, the 'cannot be displayed' message (which you will see if you don't have a Java-capable/enabled browser) should be replaced by an <IMG> tag to load a default image.

* Source Code

I'd really appreciate it if you didn't sit there thumping the Reload button to page through all the different images, as this not only loads the server unnecessarily, but it'll do funny things to my server logs. If you want to see them all, they're displayed on a page of their own, or you can just hit the Back/Forward buttons a few times.

[raingod:resources:javascript] -- [previous][up][next][links][home]