In this article downloads on MDN, it says we can use downloads api to donwload a file, but code in the example of that article
var downloading = browser.downloads.download({
url : downloadUrl,
filename : 'my-image-again.png',
conflictAction : 'uniquify'
});
downloading.then(onStartedDownload, onFailed);
will lead to Uncaught ReferenceError: browser is not defined
.
I ran this code in chrome console pannel. Did I miss something?
In this article downloads on MDN, it says we can use downloads api to donwload a file, but code in the example of that article
var downloading = browser.downloads.download({
url : downloadUrl,
filename : 'my-image-again.png',
conflictAction : 'uniquify'
});
downloading.then(onStartedDownload, onFailed);
will lead to Uncaught ReferenceError: browser is not defined
.
I ran this code in chrome console pannel. Did I miss something?
- 1 After the @Quentin's answer, do you still need how to download file in all browsers without using this downloads api – Ayoub Touba Commented Nov 3, 2020 at 9:12
- 1 @Youba I think I can use <a> to make download action, maybe. – yuan Commented Nov 3, 2020 at 9:16
1 Answer
Reset to default 7Look at the section of the MDN documentation that page appears in. The feature is only available to browser extensions, not to regular webpages (which is the context the Console runs in if you open it against a regular page).