0
我的代碼是像波紋管:linkElement.dispatchevent對象不支持此操作IE
var file = new Blob([response.data], { type: 'application/pdf' });
if (file.size != 0) {
var objectUrl = URL.createObjectURL(file);
var linkElement = document.createElement('a');
linkElement.setAttribute('href', objectUrl);
linkElement.setAttribute("download", fileName);
var clickEvent;
//This is true only for IE,firefox
if (document.createEvent) {
// To create a mouse event , first we need to create an event and then initialize it.
clickEvent = document.createEvent("MouseEvent");
clickEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
}
else {
clickEvent = new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true
});
}
linkElement.dispatchEvent(clickEvent);
此代碼在Chrome & mozila,只能用IE 10以上問題的罰款。
任何人都可以幫助我,讓它工作嗎?
謝謝。