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);