<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <button onclick="downloadFile()">Download</button> <script> function downloadFile() { var request = new XMLHttpRequest(); request.responseType = "blob";
// 传入文件链接 request.open("GET", "http://124.128.28.25/20200524140900315079.pdf"); request.onload = function () { var url = window.URL.createObjectURL(this.response); var a = document.createElement("a"); document.body.appendChild(a); a.href = url; a.download = "your_download.pdf" a.click(); } request.send(); } </script> </body> </html>