Triggering a file download without any server request

前端 未结 4 1310
粉色の甜心
粉色の甜心 2020-12-06 05:43

Greetings,

I\'m working on a JS-based application that does some complex work and logs some information (actually, up to hundreds of lines) on a

4条回答
  •  执笔经年
    2020-12-06 06:47

    You can set the content-type in the data: URL, Something like this:

    data:text/plain,this is some text
    

    However, that still has the problem of the browser automatically rendering it as text. You really have two options that i can see. One is that you set the type to some kind of binary type so that the browser doesn't try and render it, or that you have the type as text/plain and get the user to right-click and save as. Maybe something here can help?

提交回复
热议问题