Using HTML5/JavaScript to generate and save a file

后端 未结 17 1718
有刺的猬
有刺的猬 2020-11-21 07:30

I\'ve been fiddling with WebGL lately, and have gotten a Collada reader working. Problem is it\'s pretty slow (Collada is a very verbose format), so I\'m going to start conv

17条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-21 07:44

    try

    let a = document.createElement('a');
    a.href = "data:application/octet-stream,"+encodeURIComponent('"My DATA"');
    a.download = 'myFile.json';
    a.click(); // we not add 'a' to DOM so no need to remove

    If you want to download binary data look here

    Update

    2020.06.14 I upgrade Chrome to 83.0 and above SO snippet stop works (due to sandbox security restrictions) - but JSFiddle version works - here

提交回复
热议问题