xanti
06-05-2007, 02:31 PM
I'm putting together an online shop for a friend and am trying to implement 'slideshows' of a couple of images for each product, triggered by previous/next buttons, with each image capable of triggering a popup window containing a larger version of the image when clicked on.
I've spent days trawling through scripts and can't find anything that fits the bill. I found what looks to be a good but huge script at www.barelyfitz.com but it's way over the top for my needs and too complex for my basic knowledge to work out what I need to add and take away. I found another nice short script that does exactly what I want except that I can't have more than one instance of it on a page. I managed to adapt scripts so that I've got a whole series of slideshows that trip through their images fine and trigger empty(!) popup windows. I've tried all sorts of things, but I can't work out what to add to the script to get the popup window to display the larger image.
The script below is pared back to its basic building blocks minus any of my attempts to create the link to the larger image. Can anyone tell me what to add to get the larger images into the popup windows, or point me in the direction of a better script?
HTML:
<div>
<a href="javascript:popupWindow();"><img src="../images/img1_sm.jpg" alt="Click image to enlarge" name="products1" /></a>
</div>
<br />
<div>
<a onmouseover="changeimage('button1',selector2)" onclick="changeimage('products1',img1)" onmouseout="changeimage('button1',selector1)"><img src="../images/prev_off.gif" width="10" height="14" alt="image selector button" name="button1" border="0" /></a>
<a onmouseover="changeimage('button2',selector4)" onclick="changeimage('products1',img2)" onmouseout="changeimage('button2',selector3)"><img src="../images/next_off.gif" width="10" height="14" alt="image selector button" name="button2" border="0" style="padding-left:10px" /></a>
</div>
Javascript (in separate .js file):
selector1 = new Image(10,14);
selector1.src = "../images/prev_off.gif";
selector2 = new Image(10,14);
selector2.src = "../images/prev_on.gif";
selector3 = new Image(10,14);
selector3.src = "../images/next_off.gif";
selector4 = new Image(10,14);
selector4.src = "../images/next_on.gif";
img1 = new Image(180,249);
img1.src = "../images/img1_sm.jpg";
img2 = new Image(150,280);
img2.src = "../images/img2_sm.jpg";
[etc]
function changeimage (imgTagName,imgObj)
{
if (document.images)
{
document.images[imgTagName].src = imgObj.src
}
}
function popupWindow(url) {
window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars =no,resizable=yes,copyhistory=no,width=450,height=600,screenX=150,screenY=150,top=150,left=150')
}
I've spent days trawling through scripts and can't find anything that fits the bill. I found what looks to be a good but huge script at www.barelyfitz.com but it's way over the top for my needs and too complex for my basic knowledge to work out what I need to add and take away. I found another nice short script that does exactly what I want except that I can't have more than one instance of it on a page. I managed to adapt scripts so that I've got a whole series of slideshows that trip through their images fine and trigger empty(!) popup windows. I've tried all sorts of things, but I can't work out what to add to the script to get the popup window to display the larger image.
The script below is pared back to its basic building blocks minus any of my attempts to create the link to the larger image. Can anyone tell me what to add to get the larger images into the popup windows, or point me in the direction of a better script?
HTML:
<div>
<a href="javascript:popupWindow();"><img src="../images/img1_sm.jpg" alt="Click image to enlarge" name="products1" /></a>
</div>
<br />
<div>
<a onmouseover="changeimage('button1',selector2)" onclick="changeimage('products1',img1)" onmouseout="changeimage('button1',selector1)"><img src="../images/prev_off.gif" width="10" height="14" alt="image selector button" name="button1" border="0" /></a>
<a onmouseover="changeimage('button2',selector4)" onclick="changeimage('products1',img2)" onmouseout="changeimage('button2',selector3)"><img src="../images/next_off.gif" width="10" height="14" alt="image selector button" name="button2" border="0" style="padding-left:10px" /></a>
</div>
Javascript (in separate .js file):
selector1 = new Image(10,14);
selector1.src = "../images/prev_off.gif";
selector2 = new Image(10,14);
selector2.src = "../images/prev_on.gif";
selector3 = new Image(10,14);
selector3.src = "../images/next_off.gif";
selector4 = new Image(10,14);
selector4.src = "../images/next_on.gif";
img1 = new Image(180,249);
img1.src = "../images/img1_sm.jpg";
img2 = new Image(150,280);
img2.src = "../images/img2_sm.jpg";
[etc]
function changeimage (imgTagName,imgObj)
{
if (document.images)
{
document.images[imgTagName].src = imgObj.src
}
}
function popupWindow(url) {
window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars =no,resizable=yes,copyhistory=no,width=450,height=600,screenX=150,screenY=150,top=150,left=150')
}