ActiveXObject未定义且找不到变量:ActiveXObject [英] ActiveXObject is not defined and can't find variable: ActiveXObject

查看:1490
本文介绍了ActiveXObject未定义且找不到变量:ActiveXObject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在本地创建文本文件,当我浏览谷歌浏览器点击按钮时,它显示错误,如 ActiveXObject未定义,当我在safari中浏览时单击按钮它是显示错误,如找不到变量:ActiveXObject 。任何人都可以帮助我。我可以实现和创建文件.Thanq

i want to create text file in local, when i browse in Google chrome click of the button it is showing error like ActiveXObject is not defined and when i browse in safari click of the button it is showing error like can't find variable: ActiveXObject . any one can help me.how can i achieve and create file .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浏览器上可用。所以每个其他的useragent都会抛出错误

ActiveXObject is available only on IE browser. So every other useragent will throw an error

在现代浏览器上你可以使用文件API 文件编写器API (目前仅在Chrome上实施

On modern browser you could use instead File API or File writer API (currently implemented only on Chrome)

这篇关于ActiveXObject未定义且找不到变量:ActiveXObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆