Reputation: 3
This code is not working in any Browser
function Submit1_onclick() {
var fso, f1, ts;
var ForWriting = 2;
fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CreateTextFile("F:/test1.txt");
f1 = fso.GetFile("F:/test1.txt");
ts = f1.OpenAsTextStream(ForWriting, true);
// Write a line with a newline character.
tf.WriteLine("Testing 1, 2, 3.");
// Write three newline characters to the file.
tf.WriteBlankLines(3);
// Write a line.
tf.Write("This is a test.");
tf.Close();
}
Upvotes: 0
Views: 833
Reputation: 14655
user2965026 already gave the correct answer (typo).
But the asker also has another problem as stated in his comments: Error: Automation server can't create object
If you google this question you'll find what I already stated in my comment to your question: you need to elevate the security rights of the script:
Better is to add your site to the trusted domains (and check this option in that section), instead of opening this security hole for all websites!
Upvotes: 1
Reputation: 11
// Write a line with a newline character.
tf.WriteLine("Testing 1, 2, 3.");
// Write three newline characters to the file.
tf.WriteBlankLines(3);
// Write a line.
tf.Write("This is a test.");
tf.Close();
Change the tf
to ts
, you had a typo. And run it in IE. I tried it and it works in IE9. You can see your typos in console (Press F12).
Upvotes: 1