![](/img/trans.png)
[英]javascript:document.forms[0].submit() does not work with IE10
[英]createObjectURL does not work in ie10
我正在从indexedDB读取base64编码的文件,并尝试将其链接为Blob网址。 下面的代码在Chrome中工作正常,但是当我单击ie10中的链接时,没有任何反应。 我可以在链接的属性上看到href为blob:66A3E18D-BAD6-44A4-A35A-75B3469E392B,这似乎是正确的。 有人看到我在做什么错吗?
下载附件
//convert the base64 encoded attachment string back into a binary array
var binary = atob(attachment.data);
var array = [];
for(var i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i));
}
//create a blob from the binary array
var myBlob=new Blob([new Uint8Array(array)], {type: attachment.content_type});
//create a url hooked to the blob
downloadURL = (window.webkitURL ? webkitURL : URL).createObjectURL(myBlob);
//set the attachment link to the url
$('#attachmentLink').attr("href", downloadURL);
$("#attachmentLink").text(fileName);
弄清楚了。 IE10不想在新窗口中打开Blob网址,因为我上面的代码正在尝试这样做。 仅当将blob URL设置为img标签的src来显示我的文件时,我才能使此工作正常,幸运的是,该文件还是图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.