var text = "this is the content";
var name = "myfilename.txt";
var type = "text/html";
var a = document.getElementById("a");
a.style.display = "block";
var file = new Blob([text], {type: type});
a.href = URL.createObjectURL(file);
a.download = name;