本来是点击后js加上a标签的href属性。但是需要一进入页面就直接链接完整下载地址

<a name="file" download="filename" href="filepath">filename</a>
//filename   ->  a.docx
//filepath   -> /uploadFile/20190802/201908020955486975.docx

**a标签链接的图片会直接打开,覆盖页面,需要加上 target **

<a name="file" download="filename" href="filepath" target="_blank">filename</a>
//filename   ->  a.docx
//filepath   -> /uploadFile/20190802/201908020955486975.docx
<script>
$(document).ready(function () {
        //给file前加上当前主机网址
        $.each($("a[name='file']"), function (k, v) {
            $(v).attr("href", 'http://' + window.location.host + $(v).attr("href"));
        });
    })
</script>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-07-20
  • 2021-06-23
  • 2021-08-29
猜你喜欢
  • 2021-11-19
  • 2021-12-12
  • 2021-11-19
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案