To trigger the "Save As" dialog for any resource (blob:
, http:
, whatever permitted scheme), use the download
attribute of an anchor. This is supported since Firefox 20.
Example: A bookmarklet that presents the current page as a download:
javascript:(function() {
var a = document.createElement('a');
a.href = location.href;
a.download = 'filename.html';
document.body.appendChild(a);
a.click();
a.parentNode.removeChild(a);
})();
To trigger the Open
dialog, create an <input type="file">
, and click()
it. For many examples, see Using files from web applications.