Hello
Is there a way to create txt file via html to be save on the user device to download or save.
So the way is to save the user information on the device rather than using webhooks to save it on a server then redirect the user to download the exported information file text
The code below can run on any browser and without the need to have any certain library
I tried the rich text but it didn’t work.
Any other ideas ?
<html>
<head>
<title>Javascript - Create Text file</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}
textarea {
font-family: Arial, Helvetica, sans-serif;
padding: 5px;
}
</style>
</head>
<body>
<button type="button" id="btnSave" onclick="save()">SAVE</button>
<script>
function save() {
var data = "my information export";
var c = document.createElement("a");
c.download = "user-text.txt";
var t = new Blob([data], {
type: "text/plain"
});
c.href = window.URL.createObjectURL(t);
c.click();
}
</script>
</body>
</html>```