submit提交表单不跳转页面,及刷新页面
作者:互联网
<!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="终止申请书" 这个属性是下载文件重命名的(只有谷歌、火狐等浏览器支持);
标签:function,jQuery,return,myiframe,submit,iframe,跳转,loaded,页面 来源: https://www.cnblogs.com/wwwc/p/15508149.html