The download
attribute is not implemented in Internet Explorer.
http://caniuse.com/download
For Internet explorer you can use the "SaveAs" command.
A note about security:
Browsers serve 2 masters.
Browsers must serve the user's request to save content to their local drive.
Browsers must also restrict potentially malicious code from automatically downloading bits onto the users local drive.
To reconcile the 2 tasks, browsers take the approach that users can download content to their local drive after some confirming process (like a Save button).
Using a[0].click();
to confirm for the user runs contrary to the browser's attempt to provide security.
FileSave.js is a cross-browser library that will save your canvas to the users local drive. It conforms to security issues by requiring the user to click a button to OK the download.
https://github.com/eligrey/FileSaver.js/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…