2015-06-06 51 views
0
var xhr = new XMLHttpRequest(); 
xhr.open('GET', 'https://supersweetdomainbutnotcspfriendly.com/image.png',true); 
xhr.responseType = 'blob'; 
xhr.onload = function(e) { 
var img = document.createElement('img'); 
img.src = window.URL.createObjectURL(this.response); 
document.body.appendChild(img); 
}; 

xhr.send(); 

通过使用这我可以得到的图像,但默认的大小。所以请告诉我如何设置该图像的宽度和高度?如何在Chrome应用程序中设置图片的宽度和高度?

回答

0

您可以在下面var img = document.createElement('img');

img.setAttribute('width', '100'); 
img.setAttribute('height', '100'); 
+0

添加两行三江源这么多。 –

相关问题