+ 2

Looking for suggestions regarding pseudo backup/restore method.

Greetings fellow coders! I designed a web page for work to store common issue:resolution pairs as key:value pairs in the browser local storage. Now im trying to find a viable method to backup the data pairs to an external file that can then be restored in the case of data loss. I found some javascript that takes a textarea value and saves it to a .txt file and can unpack a .txt file to the same text area. I have added code to populate the text area with `localStorage.setItem('${key}', ${value})` with the saved pairs, for each pair in storage. I was trying to find a way to assign the new textarea.value in a way that it would run the setItem actions to reassign the keys. I have also put some thought into making arrays for keys and values. Any ideas or input are greatly appreciated! Both pages are saved and shared under my code, for reference

8th Apr 2019, 11:33 PM
Ryan James
Ryan James - avatar
3 Respostas
+ 2
I found a viable solution by using document.write, still working out the exact code, but this should work
10th Apr 2019, 9:22 PM
Ryan James
Ryan James - avatar
+ 1
I have updated my txt saver code with an attempt to create a script element with the file output as the text node and append that to the head element of a document.write function call. Am i misunderstanding the .appendChild method?
10th Apr 2019, 11:38 PM
Ryan James
Ryan James - avatar
+ 1
Project complete! The code does not work in the playground as expected... but if you save it locally, it works like a charm!
11th Apr 2019, 5:45 PM
Ryan James
Ryan James - avatar