两个页面有父子关系才行,window.opener.textID.value = "ksdlfjasl"

解决方案 »

  1.   

    我用第一个页面打开第二个页面是这样写的
    window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
    请问怎么才能让他们之间有父子关系?
    想在第二个页面关闭时把第二个页面的text2的值传到第一个页面种的text1去,具体该怎么写?
    小弟我是个新手,请各位大哥务必要鼎力帮助呀,我给大家施礼了
      

  2.   

    1.-----把下面这段代码保存为:javascript.htm---------------
    <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    <!--
    function button1_onclick() {
    window.open("Javascript.htm","New","left=100,top=100,width=400,height=200");
    }//-->
    </SCRIPT><INPUT type="button" value="打开测试页" id=button1 name=button1 LANGUAGE=javascript onclick="return button1_onclick()">
    <INPUT type="text" id=text1 name=text1>2.把这段代码保存为:Javascript.htm---------
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    </HEAD>
    <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    <!--
    function text1_onkeyup() {
    try{
    opener.text1.value=text1.value;
    }catch(e){
    alert(e.description);
    }
    }//-->
    </SCRIPT><BODY><P>请输入值:
    <INPUT id=text1 name=text1 LANGUAGE=javascript onkeyup="return   text1_onkeyup()" style="LEFT: 8px; TOP: 16px"></P>
    <P>在页面LookScript.htm的TextBox中的值会和你输入的同步;</P></BODY>
    </HTML>--------------------
    然后就可以看到传递过程,如果是窗口是父子关系的话,把opener.text1.value=text1.value改为:parent.text1.value=text1.value即可
      

  3.   


    var nw=window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );form2.text2.value=window.opener.form1.text1.value
      

  4.   

    我是这样做的,不知道对你有没有用第一个页面:
      function frmLoad()
         {
    sResult = window.showModalDialog("wfLogin.aspx",window,"dialogHeight:  301px;dialogwidth:401px;center:yes;scroll:no;status:no");
    if (sResult != null)
    {
      document.Form1.txtName.value = sResult.UserName;
      document.Form1.txtPassword.value = sResult.Password;
    }
         }
         //调用第二个页面时让他返回参数,这个参数是object类型的,我这里返回的是用户名,密码;第二个页面:
        function loginConfrim()
           {

    var result = new Object();
    result.UserName = document.wfLogin.txtName.value;
    result.Password = document.wfLogin.txtPassword.value;

    window.returnValue = result;
    window.close();
    }这样在第二个页面关闭时result参数就被返回了。另外:第一个页面可以用隐藏框来接受返回参数,这样在C#中
    可以用this.Request ["隐藏框名"]来访问他。