diff options
Diffstat (limited to 'src/Lib/File.ml')
-rw-r--r-- | src/Lib/File.ml | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Lib/File.ml b/src/Lib/File.ml new file mode 100644 index 0000000..0089001 --- /dev/null +++ b/src/Lib/File.ml @@ -0,0 +1,12 @@ +let download filename content = + let a = + H.a + [| HA.href ("data:text/plain;charset=utf-8," ^ URI.encode content) + ; HA.download filename + ; HA.style "display:none" + |] + [| |] + in + let () = Element.append_child Document.body a in + let () = Element.click a in + Element.remove_child Document.body a |