有人可以帮助我理解为什么它在FF中不起作用以及我需要做些什么才能使其起作用吗?
index.html
<meta charset="utf-8">
<script type="application/javascript"
src="https://unpkg.com/webextension-polyfill@0.2.1/dist/browser-polyfill.min.js">
</script>
<script>
function onStartedDownload(id) {
console.log(`Started downloading: ${id}`);
}
function onFailed(error) {
console.log(`Download failed: ${error}`);
}
var downloadUrl = "https://sample-videos.com/img/Sample-jpg-image-50kb.jpg";
var downloading = browser.downloads.download({
url : downloadUrl,
filename : 'my-image-again.png',
conflictAction : 'uniquify',
saveAs : 'true'
});
downloading.then(onStartedDownload, onFailed);
</script>
我只使用一个文件index.html
downloads API的download()函数根据文件的URL和其他可选首选项下载文件。
代码段
function onStartedDownload(id) {
console.log(`Started downloading: ${id}`);
}
function onFailed(error) {
console.log(`Download failed: ${error}`);
}
var downloadUrl = "https://sample-videos.com/img/Sample-jpg-image-50kb.jpg";
var downloading = browser.downloads.download({
url : downloadUrl,
filename : 'my-image-again.png',
conflictAction : 'uniquify',
saveAs : 'true'
});
downloading.then(onStartedDownload, onFailed);
<meta charset="utf-8">