图片自适应
<img src="1.jpg" onload="GetF.call(this,20,100)"/>
<script language="JavaScript">
function GetF(maxW,maxH){
var img = new Image();
img.src = this.src;
var maxWidth = maxW;
var maxHeight= maxH;
alert(img.width + "\n" + img.height);
bi = img.width / img.height;
bili = maxWidth / maxHeight;
alert(bi + ‘ ‘ + bili);
if(bili >= bi )
{
if( img.height > maxHeight )
{
this.height = maxHeight
}
}else
{
if( img.width > maxWidth )
{
this.width = maxWidth;
}
}
}
</script>