这个问题在这里已经有了答案:
ActiveXObject in Firefox or Chrome (not IE!)
(4 个回答)
8年前关闭。
我想在本地创建文本文件,当我在 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()'>
最佳答案
ActiveXObject
仅在 IE 浏览器上可用。所以所有其他用户代理都会抛出错误
在现代浏览器上,您可以改用 File API或 File writer API (目前已实现only on Chrome)
关于javascript - ActiveXObject 未定义,找不到变量 : ActiveXObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11101641/