bigosmallm edited a comment on issue #838:
URL: https://github.com/apache/royale-asjs/issues/838#issuecomment-633303391


   I believe you can initiate a download without the need for an explicit click 
action from the user.  This seems to work:
   
   ```var saveData = (function () {
       var a = document.createElement("a");
       document.body.appendChild(a);
       a.style = "display: none";
       return function (data, fileName) {
           var json = JSON.stringify(data),
               blob = new Blob([json], {type: "octet/stream"}),
               url = window.URL.createObjectURL(blob);
           a.href = url;
           a.download = fileName;
           a.click();
           window.URL.revokeObjectURL(url);
       };
   }());
   
   var data = { x: 42, s: "hello, world", d: new Date() },
       fileName = "my-download.json";
   
   saveData(data, fileName);
   ```
   
   Source: https://jsfiddle.net/koldev/cW7W5/


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to