Created
May 3, 2020 10:05
-
-
Save ochilab/7dfa6f8dd56d46a3f12e3ed087a74e77 to your computer and use it in GitHub Desktop.
JavaScriptでデータをファイルとしてダウンロードさせる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function downloadFile() { | |
var content="aaaa,bbbbb,ccccc"; | |
var blob = new Blob([ content ], { "type" : "text/csv"}); | |
var downLoadLink = document.createElement("a"); | |
downLoadLink.download ="test.csv"; | |
downLoadLink.href = window.URL.createObjectURL(blob); | |
downLoadLink.dataset.downloadurl = ["text/plain", downLoadLink.download, downLoadLink.href].join(":"); | |
downLoadLink.click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment