Is it possible to create and download a .txt file using only JavaScript (no server-side programming !), and save it on local drive, without displaying browser \"Save file\"
Rickard Staaf's answer is outdated. To download a file in javascript locally without prompting a dialog box, be sure to enable it in your browser settings (chrome >> settings >> advanced >> downloads and turn off 'Ask where to save each file before downloading'.
Subsequently, you can write a simple text file like so using blob
objects:
function save() {
var content = ["your-content-here"];
var bl = new Blob(content, {type: "text/plain"});
var a = document.createElement("a");
a.href = URL.createObjectURL(bl);
a.download = "your-download-name-here.txt";
a.hidden = true;
document.body.appendChild(a);
a.click();
}
No not without browser plugins, that would be a big security risk.