Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use web browser download api?

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?

like image 661
innocentDrifter Avatar asked Oct 30 '25 08:10

innocentDrifter


1 Answers

Look 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).

Screenshot of MDN demonstrating the above

like image 58
Quentin Avatar answered Oct 31 '25 23:10

Quentin