HI WELCOME TO KANSIRIS

create a file using javascript in web browser on client side

Leave a Comment
<!DOCTYPE html><html><body><h2>Kansiris Javascipt example</h2><a id="export" class="myButton" download="" href="#">export</a><script>
const blob = new Blob([stage.elaboration], { type: "text/csv" });
  if(window.navigator.msSaveOrOpenBlob) //IE & Edge
  {
    //msSaveBlob only available for IE & Edge
    window.navigator.msSaveBlob(blob,"kansiris.txt");
  }
  else //Chrome & FF
  {
    const url = window.URL.createObjectURL(blob);
    const anchor = document.createElement("a");
    anchor.href = url;
    anchor.download = "kansiris.txt";
    document.body.appendChild(anchor); //For FF
    anchor.click();
    //It's better to remove the elem
    document.body.removeChild(anchor);
</script></body></html>

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.