已废弃
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.0 KiB

2 years ago
layui.define(["layer", "jquery"], function (exports) {
var iframeEdit = {
populateIframe: function (iframe, url, headers) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onreadystatechange = handler;
xhr.responseType = 'blob';
headers.forEach(function (header) {
xhr.setRequestHeader(header[0], header[1]);
});
xhr.send();
function handler() {
if (this.readyState === this.DONE) {
if (this.status === 200) {
// this.response is a Blob, because we set responseType above
iframe.src = URL.createObjectURL(this.response);
} else {
console.error('XHR failed', this);
}
}
}
},
setPDF: function (blob) {
document.querySelector('#blob').src = URL.createObjectURL(blob);
}
};
exports('iframeEdit', iframeEdit);
})