在下载内容之前刷新页面?

时间:2021-02-10 19:15:31

标签: javascript html time async-await

所以我一直在开发一个图片分享网站,类似于imgBB。我的网站下载功能有问题!我主要编写网站的后端代码,所以我对前端的了解不多。我正在尝试使用以下代码下载图像:

//Javascript
document.getElementById('downloadImage').src = 'images/image.png';

<!--HTML-->
<!--The Download() function will be explained in a bit.-->
<button onclick="Download()" id="downloadImage">Download Image</button>

我需要在下载发生之前刷新页面。我尝试了以下代码但没有成功。

function Download() {
  window.location.reload();
    document.getElementById('downloadImage').src = 'images/image.png'
};
//The HTML page is the same.

我也用 async/await 函数尝试过这个,但也没有运气。

重点

在下载内容之前刷新页面。

有人可以帮我解决这个问题吗?

0 个答案:

没有答案