|
Javascript code to create a text file
<html>
<h2>Create Text file in JavaScript</h2>
<script>
function createFile(){
var object = new ActiveXObject("Scripting.FileSystemObject");
var file = object.CreateTextFile("C:\\Hello.txt", false);
file.WriteLine('Hello World');
file.WriteLine('Hope is a thing with feathers, that perches on the soul.');
file.Close();
}
</script>
<input type="Button" value="Create File" onClick='createFile()'>
</html>
This code doesn't work, it throws error
Uncaught ReferenceError: ActiveXObject is not defined
When opened in google chrome version 24.0.1312.52 m
Can anyone help on this.
Moto of this code is to create a text file with some content using javascript
|