467,146 Members | 1,009 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,146 developers. It's quick & easy.

Rotating random images from a directory.

I have seen many Javascripts that rotate images with each load or
refresh of the page but so far all I've found require hard coding the
image filename into the script. Does anyone know of a script that
pulls images randomly from a directory? Thus I would need only add
(or delete) images from that directory and they would display on the
web page respectively. All the images are the same size (90x90) but
there are hundreds so hard coding a script is not an interesting
solution. :)

Would caching be an issue for something like this and the same picture
would keep appearing rather than a new random selection?

By "rotating" I'm referring to with each loading or refresh of the
page, not the animated-like rotating whereby the picture changes every
nn number of seconds or such. I'm just looking to display a different
picture each time the page is loaded, no more than that.

TIA
Jul 23 '05 #1
  • viewed: 2876
Share:
1 Reply


Sandy Bremmer wrote:
I have seen many Javascripts that rotate images with each load or
refresh of the page but so far all I've found require hard coding the
image filename into the script. Does anyone know of a script that
pulls images randomly from a directory? Thus I would need only add
(or delete) images from that directory and they would display on the
web page respectively. All the images are the same size (90x90) but
there are hundreds so hard coding a script is not an interesting
solution. :)


It is certainly easy to write some server side JavaScript or any other
server side script to randomly select a file name from a directory and
output the appropriate <img> element in a dynamically generated HTML page.
A client-side scripting approach doesn't make much sense for that.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by kingofkolt | last post: by
4 posts views Thread by Ian Hubling | last post: by
31 posts views Thread by Royal Denning | last post: by
10 posts views Thread by Sehboo | last post: by
3 posts views Thread by Simon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.