问题
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