Wrox Programmer Forums
BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers by Nicholas C. Zakas; ISBN: 9780764579080
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 28th, 2005, 09:50 AM
Authorized User
Join Date: Jun 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing a element of parent window in child wind


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","<i nput type=text id='txtBox' value='Y'>");

<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()


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").va lue,but still I get the same javascript error.

Any idea where am I going wrong..??

Thanks in advance..

Old June 28th, 2005, 10:26 AM
nzakas's Avatar
Wrox Author
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts

You are doing the reverse of what you are trying to do. To access a textbox in a popped up window from the main window, you must do this:

var oWin = window.open(...);
For future reference, this forum is for questions and comments directly relating to the book. Please use the general JavaScript forum for questions such as this.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing parent window from child window arnabghosh Javascript How-To 1 December 26th, 2007 01:18 AM
closed parent window when opened child window jaiwin Javascript How-To 0 October 8th, 2006 12:54 PM
Propogating changes in child window to parent Scripts82 ASP.NET 1.0 and 1.1 Basics 4 September 22nd, 2006 07:07 AM
Close Parent window on opening child window pkdev Javascript How-To 8 April 11th, 2004 12:06 PM
Accessing parent control functions from child badgolfer VS.NET 2002/2003 2 January 9th, 2004 07:49 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.