网页下载文件,下载多个文件解决方法

用iframe

// 下载文件方法
function downloadfile(url) {
    const iframe = document.createElement("iframe");
    iframe.style.display = "none"; // 防止影响页面
    iframe.style.height = 0; // 防止影响页面
    iframe.src = url;
    document.body.appendChild(iframe); // 这一行必须,iframe挂在到dom树上才会发请求
    setTimeout(() => {
        iframe.remove();
    }, 60 * 1000);
}

 

你可能感兴趣的:(web)