简体   繁体   中英

How to write into a file (.txt or .html) in javascript

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

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://docs.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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM