html页面,创建个button
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>上传文件</title>
<link rel="stylesheet" href="css/upload_file.css">
<script type="text/javascript" src="js/download_file.js"></script>
</head>
<body>
<div class="downloadFile">
<button id="downloadBtn">下载附件</button>
</div>
</body>
</html>
download_file.js:
$(function(){
$("#downloadBtn").click(function(){
var a = document.createElement('a');
var file_name = "xxxx";
a.href = "https://www.xxx.com/xxxxxxxx.doc";
a.download = file_name;
a.click();
})