Actually you don't need a page refresh at all. In my opinion, this is by far the easiest way to retain the scrollbar in its position, while not annoying the user with an unneeded page reload. However, my answer falls under the client side part of this forum, so this thread might get moved.
All you need to do is:
- Either create an image element and append it to the div where you display the full size image (if no image exist)
- Or update the src attribute of the existing image
So, when you create the code for your thumbnails, include an onclick event with the filename (or URL if you prefer) of the full size image:
<script type="text/javascript">
function displayFullSize(src) {
var d = document;
var dest = d.getElementById('picGoesHere');
var imgs = dest.getElementsByTagName('img');
if (imgs.length > 0) {
imgs[0].src = "http://somewhere.com/original/"+src;
}
else {
var img = d.createElement('img');
img.alt = "";
img.src = "http://somehwere.com/original/"+src;
dest.appendChild(img);
}
}
</script>
</head>
<body>
<div>
<img src="http://somewhere.com/thumbnail/thumb1.jpg" alt=""
onclick="displayFullSize('full1.jpg');"/>
<img src="http://somewhere.com/thumbnail/thumb2.jpg" alt=""
onclick="displayFullSize('full2.jpg');"/>
</div>
<div id="picGoesHere"></div>
This obviously requires javascript enabled, but afaik, you can't set the scrollbar position without it anyway. And to do that, you'd
document.getElementById('yourscrollbar').scrollLeft = NN;
Where NN is a number you'd have to calculate according to what image was clicked so you know how far you need to scroll.