post 提交 到新窗口 打开

post一个表单 但是想再新窗口打开 以前没用过

网上搜索了下

XML/HTML代码
  1. 在开发web中,有很多小技巧。如果用心留意,是非常管用的,但这些小技巧有非常多,以至我们无法记住。   
  2.   
  3. 在网上找又信息很少,还是记下来 以备以后用得着的时候。   
  4.   
  5. 背景:有时候我们做web开发的时候为了提供交互性,需要将表单提交,但结果要显示在新的窗口中,在IE中   
  6.   
  7. 新的窗口有很多限制,比如去掉工具栏、菜单栏、地址栏、规定高度、宽度等等。   
  8.   
  9. 很多人会用js函数 window.open(),但这个函数只能GET提交,不能POST提交。在我们开发的过程中往往经常用POST提交。   
  10.   
  11. 解决这个问题的思路是:先用window.open()打开一个新的窗口,然后在表单中指定提交的target为刚刚打开的窗口即可。   
  12.   
  13. 例子代码:   
  14.   
  15. <form name="query_notice_form" target="_blank"  
  16.  action="<c:url value="/abc/xxxx.do"/>method="post"><input  
  17.  type="hidden" name="currType"></form>     
  18.   
  19. function showNoticeDetail(obj) {   
  20.  window.open('about:blank',"_blank","height=400,width=820,status=yes,toolbar=no,menubar=no,location=no");   
  21.  query_notice_form.submit();   
  22. }   

没仔细看 就看到了 target="_blank"
试下竟然可以 弄好再看下 感觉没这么复杂

 

XML/HTML代码
  1.     <div class="pR_6">  
  2.     <form name="compare'.$key.'" method="post" action="http://product.xxxx.com/products/product_comp.php" target="_blank">             
  3.                <div class="pR_61"><span onclick="document.compare'.$key.'.submit();" style="cursor:pointer"><img src="'.$pker_proid_pic.'" width="40" height="60" /><img src="http://icon.xxxx.com/product/detail/pk.jpg" /><img src="'.$pked_proid_pic.'" width="40"  height="60"/></span></div>  
  4.             <br clear="all" />  
  5.             <a onclick="document.compare'.$key.'.submit();" style="cursor:pointer">'.cnsubstr($pker_proid_name,10).' PK '.cnsubstr($pked_proid_name,10).'</a>  
  6.             <input type="hidden" name="pro_id[]" value="'.$value['pker_proid'].'" />  
  7.             <input type="hidden" name="pro_id[]" value="'.$value['pked_proid'].'" />  
  8.             <input type="hidden" name="subcatid" value="57">  
  9. </form>                
  10.    </div>  

 

总结下 很多东西很简单 自己试下就可以了

自己太不细心了 必须要改正了

« 上一篇 | 下一篇 »

发表评论

评论内容 (必填):