<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>JS實(shí)現(xiàn)下載文件</title>
<script language=JavaScript>
function download(obj){
if(document.all.ifrm==null){
objIframe=document.createElement("IFRAME");
document.body.insertBefore(objIframe);
objIframe.outerHTML="<iframe name=ifrm style='width:0;hieght:0' src="+obj.href+"></iframe>";
re=setTimeout("download()",1)
}
else{
clearTimeout(re)
files=window.open(obj.href,"ifrm")
files.document.execCommand("SaveAs")
document.all.ifrm.removeNode(true)
}}
</script>
</head>
<body >
文檔列表:請(qǐng)點(diǎn)出下載<br/>
<a href="file01.doc" id="filelist" onclick="download();return false;" style="cursor:hand">文件1</a> <br/>
<a href="file02.pdf" id="filelist" onclick="download();return false;" style="cursor:hand">文件2</a>
</body>
</html>
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。