• 0

Display Image without adding filename?


Question

Is there a way to tell a javascript to display a random image from a directory?

I need to be able to have the script look at a directory full of images and then choose one randomly from the directory to display instead of having to list the images in the script. I mainly want it to support *.jpg's... or anything IE can support.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I don't think thats possible because JS is client side...

I'm presuming youre talking about looking at a directory of images on the server?

You could do this easily in PHP or ASP, but not JS

Link to comment
Share on other sites

  • 0

Easy in JS. Name your images 01.jpg, 02,jpg, 03.jpg and so on. Then set a variable in Javascript to 10 (or whatever the highest number is)

In HTML display an image that should display while Javascrip loads the image you want.

THEN in JS chose a random number within the boundaries. THEN set the src of the temp image to the new src (03.jpg for example).

Only problem is sizing, so make all pics same size.

FAR from a perfect solution, but works!

Link to comment
Share on other sites

  • 0

Here is what I'm trying to do:

https://www.neowin.net/forum/index.php?act=...=34&t=70241&hl=

This post is the main post of trying to make a local picture bar basicly using javascript. It seems better than using another program that eats memory or crashes to do it. Check out the thread and you'll see. You might want to use it too. :)

If I can make a really cool sidebar using javascript that would be cool. If I can do it with vbscript then that would be better. The problem is, I don't know vbscript and I'm kind of new to scripting, but not that new. Just need some help for a great idea.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.