核心提示:利用代码实现文件下载功能!DOCTYPE htmlhtmlmeta http-equiv=Content-Type content=text/html; charset=utf-8 /head run...
利用代码实现文件下载功能
<!DOCTYPE html> <html> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <head runat="server"> <title>文件下载</title> <script type="text/javascript"> function downLoad(){ var elemIF = document.createElement("iframe"); elemIF.src = "需要下载的url"; elemIF.style.display = "none"; document.body.appendChild(elemIF); } </script> </head> <body> <a href="#" onClick="downLoad()">点击下载</a> </body> </html>
或者直接调用a 标签的 download属性直接下载。
<a href="文件url" download="下载后文件名" >点击下载</a>