http://blog.sina.com.cn/s/blog_73c8ed1901013k70.html
if (img.complete) {
callback(img.width, img.height);
} else {
img.onload = function () {
callback(img.width, img.height);
img.onload = null;
};
};
本文介绍了一种用于获取图片实际宽度和高度的方法,通过简单的JavaScript代码实现,在图片加载完成后触发回调函数,传递图片的宽度和高度作为参数。
http://blog.sina.com.cn/s/blog_73c8ed1901013k70.html
if (img.complete) {
callback(img.width, img.height);
} else {
img.onload = function () {
callback(img.width, img.height);
img.onload = null;
};
};

被折叠的 条评论
为什么被折叠?