Skip to content

FileSaver.js Example

alidbg edited this page Jan 3, 2015 · 5 revisions
<script>
      function SaveAsFile(t,f,m) {
            try {
                var b = new Blob([t],{type:m});
                saveAs(b, f);
            } catch (e) {
                window.open("data:"+m+"," + encodeURIComponent(t), '_blank','');
            }
        }

SaveAsFile("text","filename.txt","text/plain;charset=utf-8");

</script>
Clone this wiki locally