参考回答:
(1)方法1
<script type="text/javascript">var obj=new Image();obj.src="http://www.phpernote.com/uploadfiles/editor/201107240502201179.jpg";obj.onload=function(){
alert('图片的宽度为:'+obj.width+';图片的高度为:'+obj.height);
document.getElementById("mypic").innnerHTML="<img src='"+this.src+"' />";}</script><div id="mypic">onloading……</div>
(2)方法2
<script type="text/javascript">var obj=new Image();obj.src="http://www.phpernote.com/uploadfiles/editor/201107240502201179.jpg";obj.onreadystatechange=function(){if(this.readyState=="complete"){alert('图片的宽度为:'+obj.width+';图片的高度为:'+obj.height);}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)