这是我用来制作缩略图库的代码。它工作得很好,但是当我点击缩略图时,大图像会保持扭曲。我不知道如何解决这个问题。这不完全是我自己的代码,所以我不完全理解它 - 请注意我对此非常新,并且只是出于必要性而只是跳到一个高级问题(至少对我来说)。真的很感激任何帮助!!提前致谢。
<!-- image code --><script type="text/javascript">
function mb1_getObjectByID(id,o){
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
return null;
}
function mb1_swapImg(i){
mb1Obj=mb1_getObjectByID('mb1Img'+i);
var imgAry = String(mb1Obj.value).split('|');
mb1BigImg=mb1_getObjectByID('bigImg');
mb1BigImg.src = imgAry[0];
mb1BigImg.width = imgAry[1];
mb1BigImg.height = imgAry[2];
return true;
}
</script>
<table align="center" border="0" cellpadding="3" cellspacing="0" width="100%">
<tbody>
<tr>
<td align="center" valign="top">
<div style="padding:4px;"><img alt="" border="0" height="64" id="thmb0" name="thmb0" onclick="mb1_swapImg('0')" src="[IMAGE1_URL]" style="cursor:pointer" width="43" /></div>
<input id="mb1Img0" name="mb1Img0" type="hidden" value="[IMAGE1_URL]|380|570" />
<div style="padding:4px;"><img alt="" border="0" height="64" id="thmb1" name="thmb1" onclick="mb1_swapImg('1')" src="[IMAGE2_URL]" style="cursor:pointer" width="43" /></div>
<input id="mb1Img1" name="mb1Img1" type="hidden" value="[IMAGE2_URL]|380|570" />
<div style="padding:4px;"><img alt="" border="0" height="64" id="thmb2" name="thmb2" onclick="mb1_swapImg('2')" src="[IMAGE3_URL]" style="cursor:pointer" width="43" /></div>
<input id="mb1Img2" name="mb1Img2" type="hidden" value="[IMAGE3_URL]|380|570" />
<div style="padding:4px;"><img alt="" border="0" height="64" id="thmb3" name="thmb3" onclick="mb1_swapImg('3')" src="[IMAGE4_URL]" style="cursor:pointer" width="43" /></div>
<input id="mb1Img3" name="mb1Img3" type="hidden" value="[IMAGE4_URL]|380|570" />
<div style="padding:4px;"><img alt="" border="0" height="64" id="thmb4" name="thmb4" onclick="mb1_swapImg('4')" src="[IMAGE5_URL]" style="cursor:pointer" width="43" /></div>
<input id="mb1Img4" name="mb1Img4" type="hidden" value="[IMAGE5_URL]|380|570" />
<div style="padding:4px;"><img alt="" border="0" height="64" id="thmb5" name="thmb5" onclick="mb1_swapImg('5')" src="[IMAGE6_URL]" style="cursor:pointer" width="43" /></div>
<input id="mb1Img5" name="mb1Img5" type="hidden" value="[IMAGE6_URL]|380|570" />
<div style="padding:4px;"><img alt="" border="0" height="64" id="thmb6" name="thmb6" onclick="mb1_swapImg('6')" src="[IMAGE7_URL]" style="cursor:pointer" width="43" /></div>
<input id="mb1Img6" name="mb1Img6" type="hidden" value="[IMAGE7_URL]|380|570" /></td>
<td align="center" valign="top"><img alt="" border="0" height="570" id="bigImg" name="bigImg" src="[IMAGE1_URL]" width="380" /></td>
</tr>
</tbody>
</table>