一\ 用 showModalDialog 弹出一个窗口
比如 Form1 弹出 Form2
现在要在 Form2中操作 Form1中的控件
window.parent.document.all["txtReturn"].value="fly";为什么会提示 "window.parent.document.all.txtReturn 是null或不是对象
注: txtReturn 这个是一个 INPUT 框二\ 在客户端可不可以操作 Session, 如果可以, 应该怎么做

解决方案 »

  1.   

    要用window.open方法打开的对象才能使用opener对象操作父窗体
      

  2.   

    TO: 楼上的, 如果是用 window.open方法又该如何使用window.opener.document...还是报错
      

  3.   


    opener.document.all.txtReturn
      

  4.   

    1.
    window.parent.form1.txtReturn.value="fly";
    2.
      

  5.   

    参考:
    A页面中的HTML部分:
    <form id="postForm" method="post" runat="server">
    <INPUT id="txt" type="text">
    <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
    </form>
    (BUTTON为WEB控件,文本框为HTML控件)
    _____________________________________________________________________________
    在A页面的代码(CODEBEHIND)部分:
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Button1.Attributes.Add("onclick", "window.open('b.aspx');")
        End Sub
    ————————————————————————————————————
    在B页面的HTML部分:
    <form method="post" runat="server" id="theset">
    <SELECT id="lis" size="2">
    <OPTION>abc</OPTION>
    <OPTION>efg</OPTION>
    </SELECT>
    <INPUT type="button" onclick="JScript:parent.window.opener.postForm.txt.value=window.theset.lis.options[window.theset.lis.selectedIndex].text;"
    value="Button">
    </form>
    ——————————————————————————————————————
      

  6.   

    window.opener.document.all.txtReturn.value = "fly";
      

  7.   

    你可以让Form2返回值啊。然后再Form1里面接受就可以了
    var strValue;
    strValue = window.showModalDialog("Test.htm","1,2,3","dialogWidth:400px;dialogHeight:300px;center:1");
      

  8.   

    HELP : 现在用 window.open可以实现, 但我必须用 模态的对话框
    因为某些原因, 也不能用楼上说的 返回值的办法快来人啊另 : Session可以在 客户端使用吗
      

  9.   

    parent.document.all["txtPath"].value = document.Form1.txt.value;