1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21

content / test / data / download / download-attribute-blob.html [blame]

<!DOCTYPE html>
<html>
<body>
<a download="suggested-filename" href="">link</a>

<!-- In addition to initiating a download using a Blob URL, the script below
  will immediately revoke the URL as soon as the click() event has been
  dispatched. This tests that, in addition to handling the blob URL, that
  proper lifetime extensions are in place to prevent the blob from going away
  before the download is complete. -->

<script>
var anchorElement = document.querySelector('a[download]');
var blob = new Blob(['hello world!'], {type: 'text/plain'});
var url = URL.createObjectURL(blob);
anchorElement.href = url;
anchorElement.click();
URL.revokeObjectURL(url);
</script>
</body>
</html>