1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Accessing a element of parent window in child window

Discussion in 'Programming' started by livehed, Jun 28, 2005.

  1. #1
    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
     
    livehed, Jun 28, 2005 IP