我想在本地创建文本文件,当我在 Google chrome 中浏览时单击按钮,它显示错误,例如 ActiveXObject 未定义,当我在 safari 中浏览时单击按钮,它显示错误,例如 找不到变量:ActiveXObject . 任何人都可以帮助我。我怎样才能实现和创建文件 .Thanq
<script>
function createFile() {
var object = new ActiveXObject("Scripting.FileSystemObject");
var file = object.CreateTextFile("C:\\Hello.txt", true);
file.WriteLine('Hello World');
alert('Filecreated');
file.WriteLine('Hope is a thing with feathers, that perches on the soul.');
file.Close();
}
</script>
<input type="Button" value="Create File" onClick='createFile()'>