This will create a text file ‘text.txt’ in the folder where test.hta is residing. Could use to create xml and config files with javascript for courses to manipulate later.
<html>
<head>
<script language="javascript">
function WriteToFile() {
try {
var fso, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
/* s = fso.OpenTextFile("C:\\test.txt" , 8, 1, -2); */
s = fso.OpenTextFile("test.txt" , 8, 1, -2);
s.writeline("This is a test");
s.Close();
}
catch(err){
var strErr = 'Error:';
strErr += '\nNumber:' + err.number;
strErr += '\nDescription:' + err.description;
document.write(strErr);
}
}
WriteToFile();
</script>
</head>
<body>
</body>
</html>
Source: http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20837002.html
Tech Reference: JavaScript
Leave a Reply