zoukankan      html  css  js  c++  java
  • 点击下载文件

    <!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>
  • 相关阅读:
    Redis
    Redis入门
    C#编程--语句(分支语句)
    C#编程--运算符
    C#编程--输入和输出
    C#编程进制转换
    C#语言课程11月10日
    C#语言课程11月9日
    C#语言课程11月7日
    C#语言课程11月6日
  • 原文地址:https://www.cnblogs.com/yuerdong/p/9187116.html
Copyright © 2011-2022 走看看