<!DOCTYPE html> <html> <head> <script type="text/javascript" src="./jquery-1.8.2.min.js"></script> <!-- <script type="text/javascript" src="./jquery.uploadifive.min.js"></script> <link rel="stylesheet" type="text/css" href="./uploadifive.css" /> --> <title>終止申請表單</title> </head> <style> td{ width: 180px; } </style> <body> <table> <tr> <td>申報號:</td> <td><%=projid%></td> </tr> <tr> <td>模板下載:</td> <td> <a href="<%=templatePath%>" download="終止申請書" target="_blank">申請表</a> </td> </tr> <tr> <td>上傳附件:</td> <% if(downloadPath!=null&&!downloadPath.equals("")){ %> <td> <a href="<%=downloadPath%>" target="_blank">下載已上傳文件</a> </td> <% }else{ %> <td> <form id="form1" target="framName" action="/was/zzsb/uploadZzsbFile.action" method="post" enctype="multipart/form-data" > <input type="hidden" name="belongTo" value="${nodeAttr_three.unid}"/> <input type="hidden" name="projid" value="<%=projid%>"/> <input type="file" name="file"/> <input type="submit" value="上傳" /> </form> <div > <iframe id="myiframe" src="" name="framName" style="display: none;"></iframe> </div> </td> <% } %> </tr> </table> </body> </html> <script type="text/javascript"> var myiframe = 'myiframe'; jQuery(function() { jQuery('#form1').submit(function() { var $_this = jQuery(this); $_this.attr('action', '/was/zzsb/uploadZzsbFile.action'); //TODO 根據實際情況添加驗證規則 return verify_works_publish_form(); }); iframe = document.getElementById(myiframe); if (iframe.attachEvent) { //兼容IE iframe.attachEvent("onload", function() { iframe_loaded(); }); } else { // ff, chrome iframe.onload = function() { iframe_loaded(); }; } }); function iframe_loaded() { window.location.reload(); } /** * 驗證表單 * * @access public * @return void */ function verify_works_publish_form() { return true; } </script>
download="終止申請書" 這個屬性是下載文件重命名的(只有谷歌、火狐等瀏覽器支持);