我想点击按钮时开始下载文件.
我只有文件的路径.
我该如何开始下载?
这是我到目前为止所尝试的:
$('#download_button').click(function(){
var filepath = $(this).attr('data-filepath');
var do = '<a href="'+ filepath +'" download="file">file</a>';
$(body).append(do);
});
Run Code Online (Sandbox Code Playgroud)
我做错了什么.
我从不想重定向页面.
如果安装在客户端计算机上,则在浏览器或软件中下载启动以下载文件
或者你也可以设置 top.location
$('#download_button').click(function(){
var filepath = $(this).attr('data-filepath');
top.location.href = filepath;
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16137 次 |
| 最近记录: |