During the project development process, sometimes it is not possible to directly use to download files in the system. You can use the following methods to achieve it:
<a href="#" id="help"> 帮助 </a> <script type="text/javascript"> $("#help").on("click",function(){ var flag=window.confirm("确定下载说明文档吗?"); //弹框选择是否要下载文档 if(flag){ //如果点击“确定”按钮 var url=contPath+'/download/使用文档.doc'; //系统中文件的位置 //contPath是系统路径 window.location.href=url; } }); </script>
Related recommendations:
Easy-to-read document downloader PHP How to write easy-to-read code
How to download online help documents to the local. _html/css_WEB-ITnose
MySql stored procedure learning summary Attached pdf document download
The above is the detailed content of How to implement document download with js code. For more information, please follow other related articles on the PHP Chinese website!