javascript write to file and download
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
// Start file download.
download("hello.txt","This is the content of my file :)");
Also in JavaScript:
- javascript delete cookie
- checkbox is checked jquery
- remove item from array javascript
- Run project in visual studio with iis express
- function inside function javascript
- js reduce a array of straing
- sweetalert close on custom button click
- Use the conditional operator in the checkEqual function to check if two numbers are equal or not. The function should return either "Equal" or "Not Equal".
- next.js with material ui
- get keys objet javascript
- javascript question mark
- timestamp js
- selectpicker angularjs first row empty
- count value a to b character javascript
- javascript bind event to created element
- jquery alert
- is a letter javascript
- javascript charcode
- how to use json file in nodejs
- javascript store array in localstorage
- how to use session using javascript
- how to wait till jquery post request has been made
- js check if string is integer
- jest Cross origin http://localhost forbidden