`

javascript实现提交表单至弹出窗口

 
阅读更多

 有的时候我们需要把一个form表单提交到一个window.open打开的新窗口,为什么要这样子做?因为window.open()打开的新窗口我们可以控制它的所有属性,例如我们不需要菜单栏之类的。

    代码如下:

    <SCRIPT   LANGUAGE="JavaScript">
<!--
var   previewWindow;
function   doPreview(){
if(previewWindow   ==   null){
      previewWindow   =   window.open("","Preview","width=160,height=480,scrollbars=yes");
}else   if(previewWindow.closed   ==   true){
      previewWindow   =   window.open("","Preview","width=160,height=480,scrollbars=yes");
}
var   doc       =   document.myForm;
doc.target   =   previewWindow.name;
doc.action   =   "makeilltongji.php";
doc.submit();
previewWindow.focus();
}
//-->  
</SCRIPT>

很实用的代码。

 

 

 

整理后代码

 var previewWindow   =   window.open("","Preview","width=160,height=480,scrollbars=yes"); 
document.forms[0].action="person_showTime.do";
document.forms[0].method="POST";
document.forms[0].target=previewWindow.name;
document.forms[0].submit();
previewWindow.focus();

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics