yuerdong
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div id="box">点击</div>

    <a href="./1.txt" download>下载</a>
</body>
<script>
var box = document.getElementById(\'box\');
console.log(box);
box.onclick = function (){
    download(\'1.txt\');
    var form = document.getElementsByClassName(\'form\')[0];
    console.log(form);
    console.log(form.src)
}

//  弹出对话框  可以设置大小
    //window.open (\'1.txt\', \'newwindow\', \'height=100, width=400, top=0, left=0, toolbar=no, menubar=no,                         scrollbars=no, resizable=no,location=n o, status=no\');
    //
function download(url){
    var iframe = document.createElement("iframe")
    iframe.style.display = "none";
    iframe.src = url;
    iframe.className = \'form\';
    document.body.appendChild(iframe);
}


</script>
</html>

 

分类:

技术点:

相关文章:

  • 2021-11-19
  • 2021-11-19
  • 2021-06-24
  • 2021-09-25
  • 2021-11-19
  • 2021-11-19
  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2021-11-19
  • 2021-04-28
  • 2021-11-19
  • 2021-09-21
  • 2022-02-02
相关资源
相似解决方案