1

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";
     }

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

2
  • 2
    by sending it back to your server, javascript can't save a file in the system, if you think about it it would be a security issue to have websites save files to the users computer Commented Jun 3, 2011 at 6:20
  • @lbu: i think if javascript can load the file , it can also save the file.. Commented Jun 3, 2011 at 6:22

1 Answer 1

1

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!

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.