大家好,又见面了,我是你们的朋友全栈君。
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();
})
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/234218.html原文链接:https://javaforall.cn