window.opener 返回的是创建当前窗口的那个窗口的引用,比如点击了a.htm上的一个链接而打开了b.htm,然后我们打算在b.htm上输入一个值然后赋予a.htm上的一个id为“name”的textbox中,就可以写为: window.opener.document.getElementById("name").value = "输入的数据";
或是:(如果当中的表单为Form1)
window.opener.document.Form1.name.value = "输入的数据";
以上情况我是用的window.open()
如果我用的是window.showModalDialog(),使用模态窗口的话,再用以上写法的话,就出现错误:window.opener.document为空或不是对象.请高各位大虾,使用模态窗口,为什么用opener不行了,这个问题该如何解决?

解决方案 »

  1.   

    http://hi.baidu.com/xiaolei1982/blog/item/bc07f3fd07f4be47d7887da7.html
    给你篇文章
      

  2.   

    http://www.cnblogs.com/tom791108/archive/2007/04/13/712166.html
      

  3.   

    window.dialogArguments.Form1.t1.value ,用这个试过了,怎么还是取不到父窗口的控件呀,还是显示为空或不是对象.
      

  4.   

    你open的时候有没有把window传过去showModalDialog("1.htm",window);其实说白了还是要传参数过去才行。
      

  5.   

    1.asp
    <form name="form1" method="post" action="">
      <input type="button" name="Submit" value="提交" onClick="aaa();">
      <input type="text" name="textfield">
    </form>
    <script language="JavaScript">
    function aaa(){
    var s1=window.showModalDialog("2.asp",window) //打开控制窗口
    }
    </script>
    2.asp
    <script language="JavaScript">
    window.dialogArguments.form1.textfield.value="这是在设置index1元素的值"</script>
    </script>
      

  6.   

    var s1=window.showModalDialog("2.asp",window) //打开控制窗口
    window.dialogArguments.document.form1.textfield.value="这是在设置index1元素的值"</