Forum Moderators: coopster

Message Too Old, No Replies

Show image on same page without reloading

         

kknusa

1:06 am on Jan 6, 2004 (gmt 0)

10+ Year Member



Hi guys

I echo a certain amount of images , these images are thumbnails. I want to be able to show the real enlarged image next to the thumbnail without having to reload the page. So what i'm thinking of is something like the onclick function in JS. I tried some stuff but still can't make it work.
( my whole aim is not to reload page or open a new one )
my code is something like this

for (i=0; i<count($test); i++){
echo "<a href=\"...."><img src=\"$test[$i]\"></a>";
}
tried putting a javascript function in there but wasn't successful.
i basically need to pass just $i to another function and that function onclick() will produce the image.
Hope this makes sense
thanks

mcc235

5:14 am on Jan 6, 2004 (gmt 0)

10+ Year Member



How are you loading the bigger images if you are not refreshing the page or opening a new window? Are you delivering the bigger image in the same page, but hiding it until the user clicks the thumbnail? If so you could use some css to hide the larger image, then javascript to show it. But I am not sure this is what you are looking for. Is it?

kknusa

3:24 pm on Jan 6, 2004 (gmt 0)

10+ Year Member



No i'm not loading my images before hand , i just want the big images to be displayed when the user clicks on the thumbnail. All i'm trying to do is eliminate the loading of all thumbnails again and again. This can be done using frames but is there some other way by just using the onclick function in JS.

for example onclick ( call some funtion )

jatar_k

4:40 pm on Jan 6, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld kknusa,

you could pop them up in a new window for the full size image. Just put the javascript call in the for loop and the js function in the head. A standard window.open with width and height, then you can just pass it the pic name.

kknusa

4:58 pm on Jan 6, 2004 (gmt 0)

10+ Year Member



thnks Jatar_k

But i don't want to pop them up in a new window, i want everything on one page.

httpwebwitch

5:13 pm on Jan 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have seen what you're describing on many Ebay auctions; clickable thumbnails that load a larger view in a special panel. There are pre-cooked solutions available as Dreamweaver extensions, and you'll also find a few applets out there that do the same thing. Don't bother with the applets or Flash projectors - it's easy to do with cross-browser compatible HTML.

You can do it with DHTML. "float" some dynamic layers over the page, one with each large image, with the visibility turned off. Then use your thumbnails and javascript to turn the visibility on and aff as desired.

You can also do it with javascript and regular embedded images. Make an empty panel by placing a big empty image on your page with an ID and NAME. Then replace the image by altering the "src" attribute in the DOM.

You can also do it fairly easily with an iframe. Make an iframe where you want the large image to go, and load the large image into it with

<a HREF='myimage.gif' TARGET='myiframe'>

The method you choose depends on the kind of placement and effect you prefer, and your familiarity/comfort with client-side browser programming. From your responses to the good advice offered above, it seems like an iframe is the solution you'd be most comfortable with.

I sense your reluctance to do it with a popup window, even though it is usually the best way to do what you're asking. Maybe you are concerned about the popup blockers which are becoming so common on the web.

My favourite method of showing a detailed image is the "self-destructing" popup window. I open a chromeless window (all the borders and bars turned off), sized to fit my image exactly. In the <body> tag of the new window, I put the events:

onClick='self.close();' onBlur='self.close()'

This closes the popup window when someone clicks anywhere - on (onClick) or off (onBlur) the popup window. My user testing has shown that users are comfortable with how the popup behaves, and understand intuitively how to make it appear & disappear, even though it doesn't have the persistence of a normal popup window.

Good luck!

kknusa

9:20 pm on Jan 6, 2004 (gmt 0)

10+ Year Member



thnks httpwebwitch a lot of constructive ideas you have there , i used the iframe idea and works perfect show enlarged images of thumbnails without reloading