31 users online (1 members and 30 guests)  


  Results 1 to 2 of 2

Related

  1. Replies: 1
  2. Passing value from parent window to child window    Forum: Javascript Forum
    Replies: 0
  3. Frame / Child Window Submission Issues    Forum: HTML Forum
    Replies: 1
  1. #1
    livehed's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2005
    Posts
    1

    Accessing a element of parent window in child window

    Hi,

    Below is a function in my aspx page called Parent.aspx.I'm calling it on click event of a button on this page.
    function fnParentFrmSubmit()
    {
    document.body.insertAdjacentHTML("beforebegin","<input type=text id='txtBox' value='Y'>");
    document.Form1.submit();
    }

    <input type="button" value="Submit" id="btnSubmit" onclick="javascript:fnParentFrmSubmit()">

    ...And the below function is in another page called Child.aspx which I'm calling on Page_Load event

    function fnChildWinLoad()
    {
    alert(window.opener.document.forms[0].txtBox.value)

    }

    When the user clicks on the submit button,I am submitting the form thru' client side javascript and then in the code behind

    of this page,I am opening a Child.aspx using Response.write("<script language='javascript'>window.open(Child.aspx,'abcd')")

    I am creating a textbox element dynamically and then trying to access its value in the child element.
    But I am getting javascript error 'window.opener.document.forms[0].txtBox.value' is not an object or is null.
    I tried using window.opener.document.getElementById("txtBox").value,but still I get the same javascript error.

    Any idea where am I going wrong..??

    Thanks in advance..

    Regards,
    livehed

  2. #2
    Doorknob's Avatar
    Super Newbie

    Status
    Offline
    Join Date
    Jun 2002
    Location
    Malaysia
    Posts
    316

    Re: Accessing a element of parent window in child window

    replace
    alert(window.opener.document.forms[0].txtBox.value)
    with
    window.opener.FormName.txtBox.value

    Hope that helps



Tags for this Thread