最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Is it possible to modify a html file, from which the script is called, using JS? - Stack Overflow

programmeradmin1浏览0评论

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 patible with the latest Firefox, other browsers aren't important.

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 patible with the latest Firefox, other browsers aren't important.

Share Improve this question asked Dec 30, 2010 at 8:38 bogatyrjovbogatyrjov 5,3789 gold badges38 silver badges61 bronze badges 2
  • @Alin, you can generate pages only with javascript and with data ing from various sources. Especially for the browser he targets. – Mic Commented Dec 30, 2010 at 9:16
  • Must have been blind at the moment. I missed the first line... "I'm developing the following for local use". – Alin P. Commented Dec 30, 2010 at 9:21
Add a ment  | 

3 Answers 3

Reset to default 2

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 es 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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论