简体   繁体   中英

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();

By using this i can get the image but with default size. so please tell me how do i set the width and height of that image?

You can add two lines below var img = document.createElement('img');

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM