【发布时间】:2012-06-21 12:46:17
【问题描述】:
我想在本地创建文本文件,当我在 Google chrome 中浏览时单击按钮,它显示错误,如 ActiveXObject 未定义,当我在 safari 中浏览时单击按钮显示 can't find variable: 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()'>
【问题讨论】:
-
即使在 IE 上,如果您从通过 HTTP 提供的页面执行此操作,您也会遇到安全问题。