No, using only javascript you can not write files on a server, because your javascript runs on the client side (the browser).
You need either Ajax
and a server side script (like PHP
) to handle the saving, or if you only want to use it with one browser (chat with yourself?), you can store stuff with javascript in the localstorage of the browser, but be aware that this storage does not last forever.
1
solved Save a string on a server using JavaScript and PHP