Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个用户上传的图像,它显示为一个小图标,但是我需要确定原始图片的高度和宽度。我怎样才能得到它们?
为此使用对象属性宽度和高度。看下面的例子:
var imgObj = new Image() imgObj.src = "http://www.muenzenpara.de/muenzenmotive/griechenland_euro.jpg"; alert(imgObj.width); alert(imgObj.height);
.naturalWidth/.naturalHeight,尽管它在旧版 IE 中不起作用。
.naturalWidth/.naturalHeight
http://jsfiddle.net/kBRtX/