简体   繁体   中英

How to create/write into a local txt file using Javascript or jQuery but no webserver

I'm working on a project where I need to store the data in files next to the html-file but it needs to be runnable even without internet, and without any local web server.

Could somebody tell me how to create/write a txt file what I'll use as script in my html?

Build your app using Electron (or NW.js ) and use Node's filesystem module to write your text file:

const { writeFile } = require('fs');

const data = 'Some text';

writeFile('data.txt', data, (error) => {
  console.log(error || 'Done!');
});

严重的是,即使没有Web服务器,即使在html文件所在的目录中,我也无法在计算机上创建文件?

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