Javascript Open Directory Image Viewer

You all know those open directories with pictures in it.

And you all know how annoying it can be to view them all by clicking them, or downloading them all to your hd and viewing them there.

Well, here's another way:

Add this .url to your favorites. And when you're on such an open dir, just hit the url and it will show all the .jpg, .gif, .png and .bmp's on that page.

All this actually is, is a javascript as url. This has been tested in IE6, I don't garantee it'll work in other browsers, you can try.

Here's the actual script that's in the link:

var sHTML = '<html><head><title>Fotoviewer</title></head>\n<body>\n\t<div%20align="center">\n';

for (x = 0; x < document.links.length; x++) {

       link = document.links(x).href.toLowerCase();

       if ((link.indexOf('.jpg') != -1) || (link.indexOf('.gif') != -1) || (link.indexOf('.png') != -1) || (link.indexOf('.bmp') != -1)) {

              sHTML += '\t\t<img%20src="'+document.links(x).href+'"/><br/><br/>\n'



sHTML += "\t</div>\n</body></html>";


Or in a compact one line version:


Update: Added the .toLowerCase() to link.

Update #2: Changed links(x) to links[x] to make it work in other browsers ;)


  • Nice update David. It's really cool :) and very handy.

    It's indeed very annoying to click on every picture.

    I love this script :d

  • yeah it's kinda cool, except when there are pictures with an extension like .JPG (notice the uppercase), then those pictures aren't shown, but it's still good thou (y)


  • How to get this working?

    I cant get it working..

    I want to list directory information of my /images for example.

    Wanna show the links to the image + creation date + file size.. But don't know howto :s


  • wow ! an amizing script

    is it possible to make a function like showImages(&quot;url of an opendir&quot;)

    I tried to do this but it didn't work

  • Mmm... doesn't work for me. I get the following error:

    Error: document.links is not a function

    I tried do this under Firefox 0.8 on a Linux box.

  • However, if somebody finds a more strict way (with generic functions only), then i would love to know. This is something U have been looking for quite a while now.

  • Try this app: Opendir Viewer

    You can find it on some download sites and the developer is niceapps,, if i remember correctly

  • Amazing script, thnx!
    Is it possible that too large images can be rescaled to window-size automaticly?

  • wow, amazing..

    a newbee question here...! about javascript..
    How am I going to fetch all the images inside a directory and assign them in an a array..? is that possible..?

Comments have been disabled for this content.