上面那个判断有问题,可以去掉<table width="296" height="380" border="1" cellpadding="0" cellspacing="0">
<tr>
<td style="overflow:hidden">
<img id="show_img" src="http://avatar.profile.csdn.net/1/5/7/2_woshimoccc.jpg" onclick="fun()" onload="javascript:dynimgsizeIn(this,296,380)" />
</td>
</tr>
</table><img id="AlbumImg" onload="javascript:if(this.width>100 || this.height>97)dynimgsizeIn(this,100.,97)" onclick="ChangeImage(this)" src="http://avatar.profile.csdn.net/1/5/7/2_woshimoccc.jpg") %>'
<img id="AlbumImg" onload="javascript:if(this.width>100 || this.height>97)dynimgsizeIn(this,100.,97)" onclick="ChangeImage(this)" src="http://zi.csdn.net/but(475x60).jpg") %>'
<img id="AlbumImg" onload="javascript:if(this.width>100 || this.height>97)dynimgsizeIn(this,100.,97)" onclick="ChangeImage(this)" src="http://zi.csdn.net/itcast-475-60.gif") %>'
<script>
function dynimgsizeIn(img,width,height)
{
var rwidth = width;
var rheight = height;
var twidth = img.width;
var theight = img.height; if ((twidth / theight) > (rwidth / rheight))
{
theight = (rwidth / twidth) * theight;
twidth = rwidth;
}
else
{
twidth = (rheight / theight) * twidth;
theight = rheight;
}
img.width = twidth+"";
img.height = theight+""; }
function ChangeImage(index)
{
document.getElementById("show_img").src=index.src;
alert(index.height);
}</script>
<tr>
<td style="overflow:hidden">
<img id="show_img" src="http://avatar.profile.csdn.net/1/5/7/2_woshimoccc.jpg" onclick="fun()" onload="javascript:dynimgsizeIn(this,296,380)" />
</td>
</tr>
</table><img id="AlbumImg" onload="javascript:if(this.width>100 || this.height>97)dynimgsizeIn(this,100.,97)" onclick="ChangeImage(this)" src="http://avatar.profile.csdn.net/1/5/7/2_woshimoccc.jpg") %>'
<img id="AlbumImg" onload="javascript:if(this.width>100 || this.height>97)dynimgsizeIn(this,100.,97)" onclick="ChangeImage(this)" src="http://zi.csdn.net/but(475x60).jpg") %>'
<img id="AlbumImg" onload="javascript:if(this.width>100 || this.height>97)dynimgsizeIn(this,100.,97)" onclick="ChangeImage(this)" src="http://zi.csdn.net/itcast-475-60.gif") %>'
<script>
function dynimgsizeIn(img,width,height)
{
var rwidth = width;
var rheight = height;
var twidth = img.width;
var theight = img.height; if ((twidth / theight) > (rwidth / rheight))
{
theight = (rwidth / twidth) * theight;
twidth = rwidth;
}
else
{
twidth = (rheight / theight) * twidth;
theight = rheight;
}
img.width = twidth+"";
img.height = theight+""; }
function ChangeImage(index)
{
document.getElementById("show_img").src=index.src;
alert(index.height);
}</script>
{
var rwidth = width;
var rheight = height;
var twidth = img.width;
var theight = img.height; if(twidth > rwidth && theight > rheight)
{
if(twidth/rwidth > theight/rheight)
{
img.style.height = theight * rwidth / twidth + "px"
img.style.width = rwidth + "px";
}
else
{
img.style.width = twidth * rheight / theight + "px";
img.style.height = rheight + "px";
}
}
else if(twidth > rwidth)
{
img.style.height = theight * rwidth / twidth + "px";
img.style.width = rwidth + "px";
}
else if(theight > rheight)
{
img.style.width = twidth * rheight / theight + "px";
img.style.height = rheight + "px";
}
else
{
img.style.width = img.width + "px";
img.style.height = img.height + "px";
}
}