Skip to navigation
Load a text file from the desktop with javascript
04.07.17
1. get the filename and read the text file: function import_whitelist(e){ var file = e.target.files[0]; var reader = new FileReader(); reader.onload = function(){ var s = reader.result; var o = JSON.parse(s); let db = browser.storage.local.set(o); db.then(get_whitelist0); }; reader.readAsText(file); } 2. set the event handler: document.getElementById('export_whitelist').addEventListener('click', export_whitelist); 3. include the html5 input tag in the htmlpage
Export
https://developer.mozilla.org/en-US/docs/Web/API/FileReader
Reply
Anonymous
Information Epoch 1747260118
Design for visibility.
Home
Notebook
Contact us