我原来用window.open()打开的窗口 但是不能始终在上面(没关闭前)不能操作其他的窗口
现在想用showModalDialog()  ,但是有如下几点疑问?
1、如何把父窗口(多文本框表单)的值传到showModalDialog()窗口显示?
2、在showModalDialog()窗口中如何保存这些值?保存的时候不能再弹出一个新的窗口?
3、如何把我原来的js改成用showModalDialog()来做??
我原来的js
function datacheck() { 
       input1.target="preview";
input1.action="print.asp";
var win = window.open("about:blank","preview","resizable=no,width=560,height=520,top="+     (window.screen.height-520)/2+",left="+(window.screen.width-560)/2+"");
      win.focus();
      input1.submit();
 }
<form name="input1" METHOD="POST" >
<input type ="submit" value="确认提交" onClick="datacheck();">
</form>谁有实例的?可以用来参考一下?

解决方案 »

  1.   

    showModalDialog调用格式:
    vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])
    第二个参数可以传给指定的页面,而该页面通过window.dialogArguments来取得vArguments的值。vArguments可以是任意形式的参数,比如数字、字符串、数组、JSON对象等。
    而所打开的页面,可以通过window.returnValue返回给调用页面。
    比如
    window.returnValue="OK";
    window.close();
    这样就可以返回了。而在调用页面的JS代码中vReturnValue 就取得了 "OK"这个值。数据的保存应该在调用页面,而showModalDialog所打开的页面应该只是一个处理过程。
      

  2.   


    <script language="javascript">
    function datacheck() { 
      var win = window.showModalDialog("test1.asp?x",self,"");
    }
    </script> 
    <form name="input1" METHOD="POST">
    <input type="text" name="txt" value="xxxxx">
      <input type="button" value="确认提交" onClick="datacheck();"> 
    </form> 
    test1.asp<script>
    var win;
    window.onload=function(){
      win = window.dialogArguments;
      var f = document.forms[0];
      f.txt.value = win.document.input1.txt.value;
    }
    function subit(){
      var f = document.forms[0];
      f.action = "xxxx.xx";
      f.target="hf"; // 递交到隐藏的iframe
      f.submit();
    }
    </script>
    <form>
    <input type="text" name="txt"><input type="button" onclick="subit();" value="递交">
    </form>
    <iframe name="hf" style="display:none;"></iframe>
      

  3.   

    var win = window.open("Argument1","Argument2","Argument3"); 
    /*window.open()方法的返回值win表示,当前打开的新窗口的window对象;
      对win进行操作,就是相当于在子窗口操作window对象
      参数Argument1:字符串类型,表示新打开子窗口的URL
      参数Argument2:字符串类型,新打开子窗口的名字
      参数Argument3:字符串类型,新打开子窗口的样式(设置宽、高、滚动条等等)
    */
    var rtn = window.showModalDialog(Argument1,Argument2,Argument3);
    /*window.showModalDialog()的返回值rtn表示,从模态框(就是子窗口)设置的window.returnValue
      属性的值(相当于子窗口往父窗口传值,只是用于模态)
      参数Argument1:字符串类型,表示新打开子窗口的URL
      参数Argument2:Object类型,往子窗口传值。如#1楼所言,
                      是任意形式的参数,比如数字、字符串、数组、JSON对象等
                      在子窗口中用window.dialogArguments表示 父窗口传递来的值
                      比如:Argument2为 self或者window ,就相当于把父窗体传递给子窗口
                      在子窗口操作window.dialogArguments就等于在父窗口操作window对象
      参数Argument3:字符串类型,新打开子窗口的样式(设置宽、高、滚动条等等)
    */
      

  4.   


    提交过来的数据 是用来做显示用的  不想用<input type="text" name="txt">  而是像我们平常的传递数据和接受数据那样用<%=request("jydbh")%>  
      

  5.   

    也就是弹出的模态窗口test1.asp 中  不想用<input type="text" name="txt" >格式
    而是直接
      

  6.   

    还有 无法在模态窗口使用第三方的打印控件?
    我用的是ReYoPrint 一点击就全部刷新
                                      <input type="button" id="btnPrint" value="打印预览(Alt+o)" accesskey="o" onClick="ReYoPrint.Preview()">
                                      <input type="button" id="btnPrint" value="直接打印(Alt+p)" accesskey="P" onClick="ReYoPrint.Print(true)">