js兼容火狐浏览器获取图片宽和高的方法
来源:绵阳动力网络公司  时间:2015-05-25  阅读:35

专业网站建设公司绵阳动力网络公司为大家介绍关于js兼容火狐获取图片宽和高的方法,涉及javascript图片操作的相关技巧,需要的朋友可以参考下:

<!doctype html>  
<html>  
<head>  
<meta content="text/html; charset=GBK" http-equiv="Content-Type" />  
<title>获取Image 宽高</title> 
</head>  
<body> 
<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); 
 alert(img.height); 
 } 
} 
</script> 
<input id="idcardfile" type="file" name="idcardfile" onchange="newimage(this)"/> 
<img id="img" style="display: none;"> 
</body>  
</html>

 
  • 电话咨询

  • 0816-2318288