Javascript Open Directory Image Viewer

Posted Friday, February 13, 2004 1:06 PM by CumpsD
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>";

document.body.innerHTML=sHTML;


Or in a compact one line version:

javascript:var%20sHTML='<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>";document.body.innerHTML=sHTML;

Update: Added the .toLowerCase() to link.

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

Filed under: ,

Comments

# re: Javascript Open Directory Image Viewer

Friday, February 13, 2004 7:13 AM by Randy

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

# re: Javascript Open Directory Image Viewer

Friday, February 13, 2004 10:12 AM by Dhoore

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)

greets

# re: Javascript Open Directory Image Viewer

Friday, February 13, 2004 10:35 AM by David Cumps

Just add an or in the if statement :p
Or convert to url to lowercase first

# re: Javascript Open Directory Image Viewer

Monday, February 16, 2004 12:18 PM by Davy

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
Ideas?

# re: Javascript Open Directory Image Viewer

Monday, February 16, 2004 12:26 PM by David Cumps

First of all, this is ment for open dirs like: http://users.pandora.be/tr/ms/

You add a new url to your favourites, and in the 'Url' field you pase the chunk of javascript.

Now, when you're on an open dir, click the favourite and it'll draw a new page with all the images on that page. Without you having to click each one of them.

This isn't really an info tool or something, it won't give you links, creation date or file size. It's more of a lazy tool :)

If it doesn't work when you click the favourite the first time, go back and retry, sometimes it seems to fail, but it works :)

# re: Javascript Open Directory Image Viewer

Monday, April 26, 2004 3:09 AM by Red Head

wow ! an amizing script
is it possible to make a function like showImages("url of an opendir")
I tried to do this but it didn't work

# re: Javascript Open Directory Image Viewer

Monday, April 26, 2004 11:19 AM by David Cumps

You could do a document.location.href = yoururl right before executing the javascript, so your browser first navigates to the url and then lists the images.

# re: Javascript Open Directory Image Viewer

Wednesday, May 05, 2004 1:42 PM by Ojer

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.

# re: Javascript Open Directory Image Viewer

Wednesday, May 05, 2004 2:39 PM by David Cumps

Then it's probably not a generic javascript function I guess, really not much I can do about it, this was just a quick thing for personal purposes :p

# re: Javascript Open Directory Image Viewer

Wednesday, May 05, 2004 6:22 PM by Ojer

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.

# re: Javascript Open Directory Image Viewer

Friday, June 11, 2004 3:13 AM by Johan

Try this app: Opendir Viewer

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

# re: Javascript Open Directory Image Viewer

Monday, July 19, 2004 3:02 PM by bleh

you could do this if documents.links doesn't exist:

document.links = document.getElementsByTagName('a');

# re: Javascript Open Directory Image Viewer

Tuesday, July 27, 2004 8:32 AM by Josh

Meh, it doesn't really work for me...
I prefer this one:
http://www.justlikeed.net/StripDir/

# re: Javascript Open Directory Image Viewer

Friday, January 12, 2007 1:20 AM by lily

your description is so clearly that I want to have a try.and I do like to recommend one software that you can convert Macintosh pct, pic or pict files to Windows bmp file format,that is,

MacImagesConverter,http://www.qweas.com/download/graphics/image_converters/macimagesconverter.htm

have a good time!

# re: Javascript Open Directory Image Viewer

Monday, October 15, 2007 3:08 PM by Leonard

Amazing script, thnx!

Is it possible that too large images can be rescaled to window-size automaticly?

# re: Javascript Open Directory Image Viewer

Sunday, October 21, 2007 10:43 PM by ed bill

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..?

# bermione.be &raquo; Open Directory

Friday, August 08, 2008 1:23 PM by bermione.be » Open Directory

Pingback from  bermione.be &raquo; Open Directory