vector-im-hydrogen-web/assets/download-sandbox.html

25 lines
791 B
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
2021-03-03 17:50:23 +01:00
<a id="link" href="#">Download</a>
<script type="text/javascript">
var link = document.getElementById("link");
function download(blob, filename) {
var url = URL.createObjectURL(blob);
link.href = url;
link.download = filename;
link.click();
2020-11-10 19:05:50 +01:00
URL.revokeObjectURL(url);
}
window.addEventListener("message", function(event) {
2021-03-03 17:50:23 +01:00
if (event.origin === window.location.origin && event.data.type === "download") {
download(event.data.blob, event.data.filename);
}
});
</script>
</body>
</html>