[英]How do i set the width and height of the image in chrome app?
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();
通過使用這個我可以得到圖像,但具有默認大小。 所以請告訴我如何設置圖像的寬度和高度?
您可以在var img = document.createElement('img');
下添加兩行var img = document.createElement('img');
img.setAttribute('width', '100');
img.setAttribute('height', '100');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.