Forum Moderators: open

Message Too Old, No Replies

Open image directory viewer

Found some code, can't get it to work

         

madmatt69

4:27 pm on Mar 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey everyone,

I got this code that's supposed to work like a booklet- you add it to your favourites, and then when you're at a site with an open directory (like the ones that apache creates) and it's full of images, rather than click on each image to view, you can click on the link in your favourites and it will generate thumbnails of the images.

Know what I mean?

However I can't get the code to work at all in the bookmark form, I can't add it to favourites.

Here's the code:


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;

If I cut and paste that into a .html file, and run it in explorer it doesn't work, and if I make a .js and link to it from an html file, it also doesn't work.

Anyone know what I'm doing wrong, or have a better solution?

Thanks!

orion_rus

7:59 am on Mar 4, 2005 (gmt 0)

10+ Year Member



document.links.length
this means what it reads a number of links in your document with special format. Let's i describe you it:
in a body u need to add some links to point out images it may be hidden like:
<a href='images/image.jpg' style='visibility:hidden' >link1</a>
and after all this you should put this function
<script>
your text here
</script>
This function reads all href of links and put's that much images

I hope it should work now
Good lukc to you