var img = new Image();
img.src = "aaaa.jpg";
img.onload = function(){
alert(img.height + "," + img.width);
}

解决方案 »

  1.   

    对不起,没说太清楚。
    场景是这样的:
    浏览器里有 文件上传组件<type="file" />
    点击浏览后,在不上传后台服务器的情况下,通过js预览图片,并获取图片大小。
    获取图片占用空间的大小 如:200K
    最好能获取图片的路径,这样可以在浏览器里预览。
      

  2.   


    window.URL = window.URL || window.webkitURL;
    var img = document.createElement("img");
    img.onload = function(e) {
       window.URL.revokeObjectURL(this.src);
    }
    img.src = window.URL.createObjectURL(o.files[0]);
    document.body.appendChild(img);
      

  3.   

    新版本要用FileReader对象,参考:javascript客户端图片预览,兼容最新firefox,chrome和IE大小获取要在服务器端来弄,要不就用uploadify,flash差几件
      

  4.   

         showbo 版主 给力了!谢谢。