我在尝试解决ReferenceError时遇到了很多困难:
ActiveXObject is not defined in Google Chrome.
function WriteToFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("/var/www/html/nodejsphp/Test.txt",true);
s.WriteLine('messages');
console.log("contents of file now'some sampletext'");
s.Close();
}
知道从哪里开始吗?
最佳答案
这是因为 Google Chrome 和 Mozilla Firefox(以及 Microsoft Edge)不支持 ActiveXObject
,而且从来没有、也永远不会支持。 ActiveX 在现代网络浏览器中没有地位。
只有 IE 支持 ActiveXObject
,即使如此,较新版本的 IE 也仅支持它的一部分对象(我不认为 FileSystemObject
是其中之一) )。
至于从网页在本地计算机的文件系统上创建文本文件:不,你不能这样做。 (禁用安全功能的旧版 IE 除外。)
关于javascript - ReferenceError:Chrome 和 Mozilla 中未定义 ActiveXObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45237463/