使用javascript保存html文件 [英] save html file using javascript

查看:101
本文介绍了使用javascript保存html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用javacsript来读取html文件的内容,我也改变了内容..但我无法保存该文件..
i正在读取和更改html文件的内容: p>

i am using javacsript to read the content of the html file and i also alter the contents.. but i am not able to save that file.. i am reading and altering content of html file as:

   function edittheme(headtext, totext, bodytext, footertext) {
        alert(headtext);          
        var xmlDoc;
        if (window.ActiveXObject) {
            alert('IE');
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        }
        else if (document.implementation && document.implementation.createDocument) {
        alert('moz');
            xmlDoc = document.implementation.createDocument("", "doc", null);
        }
        alert('1');
     xmlDoc.async="false";
     xmlDoc.load("newthemes/theme3ex.html");       
     alert('0000');        
     document.getElementById('txtareahead').innerHTML = headtext;         
     document.getElementById('txtareato').innerHTML = totext;
     document.getElementById('txtareabody').innerHTML = bodytext;
     document.getElementById('txtareafooter').innerHTML = footertext;
     xmlDoc.save("newthemes/theme3ex.html");       
     location.href = "MailSender.aspx";
     }

如何保存html文件...
if它不能使用JavaScript保存,有没有其他方式来保存它根据我的代码????? ..

how can the html file can be saved... if it cannot be saved using javascript , is there any other way to save it according to my code?????..

推荐答案

阅读和写作是完全不同的权利;-)所以只是因为读权限没有写权限。否则,你可以编辑你可以在网上找到的每个文件!

Reading and writing are completely different rights ;-) So only because of read-permissions there are no write-permissions. Otherwise, you could edit every file you can find in the web!

使用普通的JS不可能编写文件,但是使用HTML5和它的 FileWriter-API 。查看第一个示例。有了这个,你可以在用户hdd本地写文件。如果你想把它们保存在服务器上,你必须把它们发回来,就像lbu说的那样。

With plain JS it is not possible to write files, but with HTML5 and its FileWriter-API. Have a look at the first example. With this you can write files locally at the users hdd. If you want to save them on the server you have to send them back, just like lbu said.

这篇关于使用javascript保存html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆