日期:2014-05-16  浏览次数:20374 次

JavaScript获取图片宽度和高度
<script>
function getSize(img)
{
    if(typeof(img)!='object')
        img=document.getElementById(img);
    if(img==null)
        return;
    var image=document.createElement("img");
    image.onload=function (){
        var width=this.width;
        var height=this.height;
                alert("width:"+width+" height:"+height)
    };
    image.src=img.src;
}
</script>

?

<img src="http://profile.csdn.net/dh20156/picture/2.jpg" width="1" height="1" onload="getSize(this)">

?