I have some problem to write date to a file Test.txt by using JavaScript. I have find answer in good too but I am still can't solve it. This is my code
<script type="text/javascript">
function WriteFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile("Test.txt", 8,true);
x=document.getElementById("name").value;
fh.WriteLine(x);
fh.Close();
}
And
<form>
<input type="text" id="name"/>
<input type="button" value="Save" id="write" onclick="WriteFile()"/>
</form>
I think it's should be run well by I the simple example I see from ebook.
I am not sure with path of Test.txt. I put it in the same forder in my localhost.
What am I doing wrong?
According to http://msdn.microsoft.com/en-us/library/czxefwt8(v=vs.84).aspx it looks like you need to specify the full path for your file.
E.g.
"C:\\Test.txt"
Update:
Just tested this in IE9 and it works.
This the example you could go through:-