how to write to a file with javascript without nodejs
function convertToJSON() {
var firstname = document.getElementById('firstname').value;
var lastname = document.getElementById('lastname').value;
var email = document.getElementById('email').value;
var jsonObject = {
"FirstName": firstname,
"LastName": lastname,
"email": email
}
document.getElementById('output').value = JSON.stringify(jsonObject)
}
function saveToFile() {
convertToJSON();
var jsonObjectAsString = document.getElementById('output').value;
var blob = new Blob([jsonObjectAsString], {
//type: 'application/json'
type: 'octet/stream'
});
console.log(blob);
var anchor = document.createElement('a')
anchor.download = "user.json";
anchor.href = window.URL.createObjectURL(blob);
anchor.innerHTML = "download"
anchor.click();
console.log(anchor);
document.getElementById('output').append(anchor)
}
Also in JavaScript:
- How to remove options from selectlist in javascript?
- set variable to object without editing old object js
- how to setup icomoon in react js
- localecompare javascript
- moment to javascript date
- material ui change theme
- discord.js join voice channel
- setup the react on local machine
- class in react
- mutable array methods in javascript
- javascript to string
- electron load index.html
- get year from date javascript
- add last item array js
- delete first character javascript
- check if isset variable js
- mdn js string
- import react-router-dom
- decet wheter react app in development or production
- js detect cmd+s
- javascript array remove last
- update object in array if id exists else append javascript
- javascript function call with variable
- print javascript variable in console