2014-05-05 56 views
2

我使用的是Chrome Dev和Chrome canary,下載文件的文件名有時被稱爲Download.xlsx,而不是我命名的文件名。Html5下載屬性...有時文件名是通用的Download.xlsx

有時它的偉大工程,othertimes其

我創建了一個分離DOM節點錯誤的文件名和燒成

var link = document.createElement('a'); 
     angular.element(link) 
      .attr('download', response.data.fileDownloadName) 
      .attr('href', 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,' + response.data.fileContents); 
     link.click(); 

呈現的HTML:

<a download="Report.xlsx" href="data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,UEsDBBQAAAAIAAAAIQD8JIb71AIAA...

回答

0

行爲如果response.data.fileDownloadNameundefined,則會發生描述。在這種情況下,生成的文件名將是download.extension。但請注意,這與小寫d至少在chrome中不同,您在問題中提到D

相關問題