Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm using the following code on a list of images, when you click an image the large image changes. What I'd like is the user to be moved back to the top of the page to view the large image.
CODE:
<SCRIPT Language="JAVASCRIPT"> function imgchange(name){if(document.images){document.main.src = "images/photos/" + name; } else { document.main.src = "images/nophoto.gif"; }}</SCRIPT>Layout like this:
BIG IMAGE HEREsmall image 1
small image 2
small image 3
small image 4
small image 5
small image 6
small image 7
etcSo if you click on small image 7 the image schanges and you are moved back to the top of the page to view it.
I also pull in this function from another file:
echo "< a hre f=\"javascript:imgchange('$file_name')\"> ";
ec ho "<im g sr c=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"$displayheight\" width=\"$displaywidth\" alt=\"$thumb_file_name\">
";
Thanks Ian

I would put an anchor around the large image like so:
< a name="largeiamge" > LARGEIMAGE < /a >
Then change the links for the small images to this:
echo "< a href=\"#largeiamge\" onclick=\"javascript:imgchange('$file_name')\"> ";
echo "< img src=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"$displayheight\" width=\"$displaywidth\" alt=\"$thumb_file_name\" >";Then when you click that link the javascript will run, but the anchor link will also force the page to the top.
Michael J

That works a treat Micheal, thanks.
I didn't know how to get round adding two commands to the href.
Ian

![]() |
php mysql alphabetized an...
|
edit multiple htm files a...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |