javascript - ActiveXObject 未定义,找不到变量 : ActiveXObject

标签 javascript sencha-touch-2

这个问题在这里已经有了答案:





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 APIFile writer API (目前已实现only on Chrome)

关于javascript - ActiveXObject 未定义,找不到变量 : ActiveXObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11101641/

相关文章:

sencha-touch-2 - Sencha 触摸 : Refresh Store Content

sencha-touch-2 - 列表不显示

javascript - 从 HTML5 Canvas 中的图像中删除背景颜色

javascript - 异步 javascript HTTP 请求是在主堆栈完成之前还是之后发送

caching - Sencha 触摸2 : Cannot disable the disableCache mechanism - app does not run offline

javascript - 将 url 复制到剪贴板

javascript - 屏幕上带有标题的随机音频

javascript - 在 Node 4.3 中使用 Buffer.from 时,TypeError Base64 不是一个函数

javascript - WebKit 相当于 Firefox 的 "moz-chunked-arraybuffer"xhr responseType

css - Sencha CSS 变量覆盖被忽略