Is it possible to modify a html file, from which the script is called, using JS?
I'm developing the following for local use:
I've got a HTML page, with some content.
Is it possible to edit the content of this HTML through the browser, and save the changes on-the-fly to this same file using only JavaScript? So the users could edit the file through the browser and it would auto-save itself.
The problem is, I have no possibility to use server-side languages here. It should be compatible with the latest 开发者_Python百科Firefox, other browsers aren't important.
Nope, you can't save server-side files using only native Javascript.
However, there seem to be some Java FTP Applets around that are scriptable from JavaScript. See this SO question.
Other than that, you need something on the server side receiving and writing the data.
No, this is not possible without backend code.
If the changes are only for that user, you can parse the data of the page and store them locally. Using some of the HTML5 goodies: http://diveintohtml5.ep.io/storage.html
Then, when the user comes back, render it with a Javascript template engine.
My heart goes to PURE but there's plenty of other options if you prefer the double brackets family of templates.
If the changes are for all users, you could call a third server you own(appEngine, Amazon,...), to store the data, and deliver them through JSONP. And again render them with a JS template engine.
精彩评论