js检测所显示图片的宽高(兼容各浏览器)

js检测显示图片的宽高(兼容各浏览器)

 

 

 

  
  
  
  
  1. <img src="http://www.baidu.com/img/baidu_logo.gif" width="500" id="imgs" /> 
  2. <script> 
  3.     document.write("宽:"+imgs.width+" 高:"+imgs.height); 
  4. </script> 
  5.  
  6. <br /> 
  7.  
  8. <img src="http://www.baidu.com/img/baidu_logo.gif" id="image" /> 
  9. <script> 
  10.     document.write("宽:"+image.width+" 高:"+image.height); 
  11. </script>  

 

你可能感兴趣的:(js,图片宽高)