Is it possible to write data to file using only JavaScript?

后端 未结 10 1305
梦如初夏
梦如初夏 2020-11-21 15:45

I want to Write Data to existing file using JavaScript. I don\'t want to print it on console. I want to Actually Write data to abc.txt. I read many answered que

10条回答
  •  无人及你
    2020-11-21 16:15

    I found good answers here, but also found a simpler way.

    The button to create the blob and the download link can be combined in one link, as the link element can have an onclick attribute. (The reverse seems not possible, adding a href to a button does not work.)

    You can style the link as a button using bootstrap, which is still pure javascript, except for styling.

    Combining the button and the download link also reduces code, as fewer of those ugly getElementById calls are needed.

    This example needs only one button click to create the text-blob and download it:

    
       Write To File
    
    
    
    

提交回复
热议问题