Create text file in JavaScript

前端 未结 3 1253
别跟我提以往
别跟我提以往 2020-12-05 05:50

I am trying to create a text file using JavaScript, I know it is possible by using ActiveX object, but it runs well only on IE browsers.

My requirement is to generat

3条回答
  •  佛祖请我去吃肉
    2020-12-05 06:39

    In JavaScript, you can use the following line to ask the user for saving a text file:

    window.open("data:text/json;charset=utf-8," + escape("Ur String Object goes here"));
    

    I tested this in some popular browsers some time back but please check if it works in Safari or not.

提交回复
热议问题