Skip to content

Commit

Permalink
Use a hidden anchor element in the file demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
shoestringresearch committed Nov 2, 2023
1 parent e981aef commit 381e456
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions demo/file/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h1>Sample database import/export</h1>
</div>
<div>
<button id="file-export" disabled>Download</button>
<a id="file-download" hidden></a>
</div>
<hr>
</body>
Expand Down
5 changes: 4 additions & 1 deletion demo/file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ document.getElementById('file-export').addEventListener('click', async () => {
const url = new URL('./export', location.href);
url.searchParams.set('idb', IDB_NAME);
url.searchParams.set('db', DB_NAME);
window.open(url);

const a = /** @type {HTMLAnchorElement} */(document.getElementById('file-download'));
a.href = url.href;
a.click();
});

document.getElementById('file-import').addEventListener('change', async event => {
Expand Down

0 comments on commit 381e456

Please sign in to comment.