window.open下载文件


function openwin(url) {
    var a = document.createElement("a");
    a.setAttribute("href", url);
    a.setAttribute("target", "_blank");
    a.setAttribute("id", "camnpr");
    document.body.appendChild(a);
    a.click();
}

 通过js的ajax请求验证一个资源文件地址是否存在,存在打开连接,不存在提示!

<script src="../js/jquery-1.12.4.min.js" type="text/javascript"></script>
function svnOpen(address) {
    var response = $.ajax({
        url: address,
        type: 'HEAD',
        async: false
    }).status;

    if (response=="404") {
        alert("文件不存在!"); 
    } else {
        openwin(address);
    }
}
function openwin(url) {
    var a = document.createElement("a");
    a.setAttribute("href", url);
    a.setAttribute("target", "_blank");
    a.setAttribute("id", "camnpr");
    document.body.appendChild(a);
    a.click();
}

 

 

const a = document.createElement("a");
                document.body.appendChild(a);
                a.style = "display: none";
                a.href = canvas.toDataURL();
                a.download = name;
                a.click();
                document.body.removeChild(a);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM