2020-11-10 21:53:23 +05:30
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
</head>
|
|
|
|
<body>
|
2021-03-03 22:20:23 +05:30
|
|
|
<a id="link" href="#">Download</a>
|
2020-11-10 21:53:23 +05:30
|
|
|
<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 23:35:50 +05:30
|
|
|
URL.revokeObjectURL(url);
|
2020-11-10 21:53:23 +05:30
|
|
|
}
|
|
|
|
window.addEventListener("message", function(event) {
|
2021-03-03 22:20:23 +05:30
|
|
|
if (event.origin === window.location.origin && event.data.type === "download") {
|
2020-11-10 21:53:23 +05:30
|
|
|
download(event.data.blob, event.data.filename);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|