Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Icant.co.uk:
Image previews with DOM JavaScript (and PHP if wanted)
Jul 29, 2005 @ 10:56:28

On the icant.co.uk website, there's a pretty slick little script that can let you preview images with Javascript (and PHP if wanted in the form of a small camera icon next to the image link.

Sometimes we want to offer a visitor a preview of what is lurking behind a link, especially when it is a huge picture and there might not be a need to load it. This is where thumbnails come in handy, and it is pretty easy to use CSS to show and hide a thumbnail in modern browsers.

Using a combination of DOM Javascript (and, if you want, PHP with GD to generate the thumbnails on the fly) and some handy CSS/HTML, they show you how to make a either a simple link (that they use the camera for) or just a mouseover to create the preview.

They provide the script, of course, but they also explain things so you'll know just exactly what's going on. I tried it in a few different browsers and it seems to work pretty well, but Safari has an issue with rendering the images correctly once the link is clicked. It seems to only load chunks of it...

tagged:

Link:


Trending Topics: