Rotating random images from a directory.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sandy Bremmer

    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
  • Martin Honnen

    #2
    Re: Rotating random images from a directory.



    Sandy Bremmer wrote:
    [color=blue]
    > 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. :)[/color]

    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


    Comment

    Working...