我正在尝试从URL加载图像,然后使用它。如何将加载的图像设置在100x150
内部onload()
?
var img = new Image();
var theurl = "furits/lychee.png";
img.onload = function() {
//how can I set 100 width and 150 height?
//do something from resized image
};
img.src = theurl;
试试这个:
var img = new Image();
var theurl = 'http://www.sunhome.ru/UsersGallery/wallpapers/78/gomer-simpson-kartinka.jpg';
img.onload = function() {
this.width = 100;
this.height = 150;
document.body.appendChild(this);
};
img.src = theurl;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句