JavaScript クイック辞典
■HTML - テキストをダウンロードさせるリンク
<a id="D_CSV" href="" download="data.csv">ダウンロード</a>
■JavaScript - テキストのダウンロード準備をする
let csv = "xxxxxxxxx"; // ダウンロードさせるテキスト
let blob = new Blob([ csv ], { type : "text/plane" });
document.getElementById("D_CSV").href
document.getElementById("D_CSV").href
= window.URL.createObjectURL(blob);
※テキスト内に改行を入れる場合は、"\n"。