ローカルファイルを読み書きするサンプル(Scripting.FileSystemObject)

question:1169003191 で回答したものです。

<html>
<head>
<title></title>
<script>
var fso = new ActiveXObject("Scripting.FileSystemObject");
var path = "C:\\text.txt"

function readFile(){
  if(!fso.FileExists(path)){
    alert("ファイルが存在しません");
    return false;
  }
  var textObj = fso.OpenTextFile(path, 1);
  document.getElementById("edit").value = textObj.ReadAll();
  textObj.Close();
}

function writeFile(){
  var textObj = fso.OpenTextFile(path, 2, true);
  textObj.Write(document.getElementById("edit").value);
  textObj.Close();
}
</script>
</head>
<body>
<textarea id="edit"></textarea>
<button onclick="readFile();">READ</button>
<button onclick="writeFile();">WRITE</button>
</body>
</html>

参考:http://msdn.microsoft.com/ja-jp/library/cc409798.aspx
扱いには十分注意してください・・・。