How do I download JavaScript string as a file

前端 未结 8 809
太阳男子
太阳男子 2021-01-13 18:52

Application requests KML data through AJAX from server. This data is stored in javascript variables, and displayed in Google Earth plugin.

In javascript, how do I

8条回答
  •  Happy的楠姐
    2021-01-13 19:26

    Check out http://regany.com/blog/2014/05/30/convert-a-string-to-a-download-file-in-javascript/

    Enable popups and use the following code:

    var str = "the string you wan't to download";
    window.open('data:text/plain,' + encodeURIComponent(str));
    

提交回复
热议问题