火狐获取图片宽和高的方法

<script>
function newimage(obj) {
   a = new Image();
   var objectURL = window.URL.createObjectURL(obj.files[0]);
   var img= document.getElementById('img')
 img.src = objectURL;
    a.src = objectURL;

 img.onload=function (){
  alert(img.width)
 }

}
</script>

<input id="idcardfile" type="file" name="idcardfile" onchange="newimage(this)"/>
<img id="img" style="display: none;">

原文地址:https://www.cnblogs.com/shortboy/p/2536451.html