Save textarea content to local file using file system access API [ demo & source code ]
<button id="saveas"> save as</button>
<textarea id="textarea" style="width:100%;height:300px">Free Online HTML editor autocomplete with CSS & JS</textarea>
<script>
document.getElementById("saveas").onclick = function() {
saveFile()
}
async function saveFile() {
const opts = {
types: [{
description: 'html file',
accept: {'text/html': ['.html']},
}],
};
const newHandle = await window.showSaveFilePicker(opts);
// create a FileSystemWritableFileStream to write to
const writableStream = await newHandle.createWritable();
var textarea =document.getElementById("textarea").value
await writableStream.write(textarea);
// close the file and write the contents to disk.
await writableStream.close();
}
</script>
![Save textarea content to local file using file system access API [ demo & source code ] Save textarea content to local file using file system access API [ demo & source code ],](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju0G862pyc6MfiC5yeD0V300PDFk8L_VXrKAtiSYibDkp-b747P8LXGY45m2P6ZjlPDxN-Yz7gn2Uad5OYujNsDCO9tojwNqNShIFuPBG0owv6T7q9X72lGwstBeWlp8nky8a_tkJGriBG0phkJBH1gFZEiUzz8Snc_vJfmVIiwZs6hb4it0IEqSRyXL4/s854/manjmnt.webp)
© 2025 Manajmnt code
Comments
Post a Comment
message