ReferenceError: ActiveXObject is not defined in Chrome and Mozilla

20,561

That's because Google Chrome and Mozilla Firefox (and Microsoft Edge) don't support ActiveXObject, and never have, and never will. ActiveX has no place in modern web browsers.

Only IE supports ActiveXObject, and even then, more recent versions of IE only support it with a subset of objects (I don't think FileSystemObject is one of them).

As for creating a text file on the local machine's file system from a web page: Nope, you can't do that. (Except in old versions of IE with security disabled.)

Share:
20,561
Suraj Anand
Author by

Suraj Anand

Updated on July 22, 2020

Comments

  • Suraj Anand
    Suraj Anand almost 4 years

    I am having a lot of difficulty attempting to solve a 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();
    }
    

    Any idea where to begin?

  • Ann Zen
    Ann Zen over 2 years
    "Only IE supports ActiveXObject" Doesn't Opera support ActiveXObject?
  • T.J. Crowder
    T.J. Crowder over 2 years
    @AnnZen - Current Opera certainly doesn't. It could be that some old version of it did, at least in some limited form (for instance, maybe just new ActiveXObject("Msxml2.XMLHTTP") to create an XMLHttpRequest object for backward-compatibility with MS-only sites from the late 90's), but I don't recall that being the case (not that I'd necessarily have reason to).