<a href="javascript:DownLoad('images/1.jpg')">下载</a>
<script>
var frm = null;
var timer = null
function DownLoad(url)
{
frm = document.createElement("IFRAME");
frm.style.display = "none";
document.body.appendChild(frm);
frm.contentWindow.location.href = url
timer = setInterval(checkload,200);
}
function checkload(){
if( frm.contentWindow.document.readyState =="complete")
{
frm.contentWindow.document.execCommand("SaveAs");
clearInterval(timer)}
document.body.removeChild(frm);
}
</script>
转载于:https://www.cnblogs.com/caviare/archive/2007/05/08/739127.html