Using chrome.downloads.download, is it possible to make the file not popup the download bar?

你离开我真会死。 提交于 2020-01-01 19:43:16

问题


When I executed chrome.downloads.download, it downloads the file and popups up the download bar at the bottom and shows it, can I suppress it?

Example:

/* some code to suppress download bar */

chrome.downloads.download(
  { "url": request.ImageToDownload },
  function (downloadId){
    // ...
  }
);

回答1:


Yes, it's possible. You can fully suppress the download bar:

chrome.downloads.setShelfEnabled(boolean enabled)

Enable or disable the gray shelf at the bottom of every window associated with the current browser profile. The shelf will be disabled as long as at least one extension has disabled it. Enabling the shelf while at least one other extension has disabled it will return an error through runtime.lastError. Requires the "downloads.shelf" permission in addition to the "downloads" permission.

Make sure to restore it after you're done. The idea of this function is to allow you to build a custom UI that replaces the shelf.



来源:https://stackoverflow.com/questions/28752268/using-chrome-downloads-download-is-it-possible-to-make-the-file-not-popup-the-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!