0

does anyone know how to write into a file (.txt or .html) in javscript. I got multiple answers in google but none of them are working. Currently I am using this line :

var FileOpener = new ActiveXObject("Scripting.FileSystemObject");;
var FilePointer = FileOpener.OpenTextFile("C:\Users\sidkr\Desktop\sid.txt", 8, true);
FilePointer.WriteLine("I m a good boy");
FilePointer.Close();

But getting following error ActiveXObject is not defined

I am using google chrome for development

kboul
  • 13,836
  • 5
  • 42
  • 53
65th bit
  • 55
  • 1
  • 11
  • ActiveX is an Internet Explorer feature only. So it won't work in Chrome – musefan Jun 06 '18 at 09:15
  • if you are using any other browser then `IE` it will through that error refer to this [link](https://stackoverflow.com/a/7172981/2417602) for more info. – vikscool Jun 06 '18 at 09:16
  • This object is a Microsoft extension and is supported in Internet Explorer only, not in Windows 8.x Store apps. https://learn.microsoft.com/en-us/scripting/javascript/reference/activexobject-object-javascript – kkica Jun 06 '18 at 09:16
  • Possible duplicate of [How to read and write into file using JavaScript?](https://stackoverflow.com/questions/585234/how-to-read-and-write-into-file-using-javascript) –  Jun 06 '18 at 09:16

1 Answers1

0

From the microsoft docs

This object is a Microsoft extension and is supported in Internet Explorer only, not in Windows 8.x Store apps.

https://learn.microsoft.com/en-us/scripting/javascript/reference/activexobject-object-javascript

Take a look at this question here Is it possible to write data to file using only JavaScript?

kkica
  • 4,034
  • 1
  • 20
  • 40