2016-11-21 55 views
1

我使用有一個問題,在他們的時刻,其中在所有瀏覽器和平臺,我可以一個bse64字符串轉換爲PDF文件,但我一直無法找到解決方案,我可以指定文件名,並在Edge中自動下載文件。JS Base64編碼字符串來下載的PDF邊緣

在此先感謝您的幫助。

+0

window.top.navigator.msSaveOrOpenBlob(BLOB,文件名) – Lain

回答

2

如果我沒有記錯,這是在IE中的一個普遍問題,不只是優勢。一個可以通過使用msSaveOrOpenBlob()保存一個名爲在IE中的斑點:

var tF = 'Whatever.pdf'; 
var tB = new Blob(..); 

if(window.top.navigator.msSaveOrOpenBlob){ 
    //Store Blob in IE 
    window.top.navigator.msSaveOrOpenBlob(tB, tF) 
} 
else{ 
    //Store Blob in others 
    var tA = document.body.appendChild(document.createElement('a')); 
    tA.href = URL.createObjectURL(tB); 
    tA.download = tF; 
    tA.style.display = 'none'; 
    tA.click(); 
    tA.parentNode.removeChild(tA) 
}