473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

2nd call from child window to parent fails

Hello all,

Simple chat app, where the site owner has a master window with all requests
for chat, status of each room, etc., and child windows for each separate chat
in which the owner is engaged. When the owner closes one of his child
windows, I want to update the master window.

I understand "reasonably" well how to go about this. The master window
launches the children, and maintains an associative array to keep track of
each one. When a child closes, I want it to tell the master to remove it from
its list (this will happen on periodic polling from the master as well). So,
child.unload calls window.opener.removeMe.

The problem is that the first time a child calls removeMe on the parent, it
seems to work, but on the second I get "object doesn't support this
property...". I've stripped everything down to the barest html as follows,
where as you'll see the parentPage fires up a childPage, and the childPage
has a button to run a function in the parent. First time I click the button I
get expected behavior, but the second time I get the same "object doesn't
support..." error, even though window.opener still appears valid.

*testParent.html*
<html>
<head>
<script>
function startRequest() {
w = window.open('testChild.html', 'myChild');
}
function childCall() {
document.write('Child did this...');
}
</script>
</head>
<body onload="startRequest();">
</body>
</html>

* testChild.html *
<html>
<head>
<script>
function updateParent() {
window.opener.childCall();
}
</script>
</head>
<body>
<form>
<input type=button value="Update Parent" onclick="updateParent();">
</form>
</body>
</html>

I think I'm missing something fundamental re scope and/or lifetime, but
don't see it. Any tips are greatly appreciated.

Thanks,

Bill
Nov 19 '05 #1
1 1944
P.S. I now see the problem, but still don't understand what's happening. When
I call the parent function 'childCall()', the document.write in there is
overwriting the parent window with the child window, including location, etc.
If instead of doing document.write I do, say, divMyParentLabel='..whatever'
I'm good to go. Might be implicit open/close on the document object, or maybe
I'm not understanding the scope of the parent/child function calls and which
'document' is in play. Any additional thoughts are appreciated.

"Bill Borg" wrote:
Hello all,

Simple chat app, where the site owner has a master window with all requests
for chat, status of each room, etc., and child windows for each separate chat
in which the owner is engaged. When the owner closes one of his child
windows, I want to update the master window.

I understand "reasonably" well how to go about this. The master window
launches the children, and maintains an associative array to keep track of
each one. When a child closes, I want it to tell the master to remove it from
its list (this will happen on periodic polling from the master as well). So,
child.unload calls window.opener.removeMe.

The problem is that the first time a child calls removeMe on the parent, it
seems to work, but on the second I get "object doesn't support this
property...". I've stripped everything down to the barest html as follows,
where as you'll see the parentPage fires up a childPage, and the childPage
has a button to run a function in the parent. First time I click the button I
get expected behavior, but the second time I get the same "object doesn't
support..." error, even though window.opener still appears valid.

*testParent.html*
<html>
<head>
<script>
function startRequest() {
w = window.open('testChild.html', 'myChild');
}
function childCall() {
document.write('Child did this...');
}
</script>
</head>
<body onload="startRequest();">
</body>
</html>

* testChild.html *
<html>
<head>
<script>
function updateParent() {
window.opener.childCall();
}
</script>
</head>
<body>
<form>
<input type=button value="Update Parent" onclick="updateParent();">
</form>
</body>
</html>

I think I'm missing something fundamental re scope and/or lifetime, but
don't see it. Any tips are greatly appreciated.

Thanks,

Bill

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Filiz Duman | last post by:
Is it possible to call a javascript function based in the parent window from the child window ? I do open a pop up window from the parent window with: newwindow = window.open (...) and assign...
2
by: Bostonasian | last post by:
I am trying to append options to dropdown in parent window from option items in child window. In parent window, I have following code: <script language="javascript"> function...
2
by: Raj | last post by:
Hi All, I have a problem with trying to refresh the parent window from child window in order to update data in the parent window. The sequence of events are 1) I click a button in the parent...
2
by: SHAWN DEB ECKLEY | last post by:
Here is my situation... i have a parent window/ main app and i call a child form (type 1). the child form(type 1) gets information from a database. the user makes some choices and then some data...
1
by: adamredwards | last post by:
I have a page with some form elements that are dynamically generated. They are inserted into the dom by first cloning a node, changing the values like name, and then inserted with insertBefore(). ...
2
by: sanscrimson | last post by:
Hi! I just want to ask if it possible to call functions in parent window if the child window is created. Below is sample:...
7
by: Sheikko | last post by:
Hi all, i have an application and i wan to call another program into it, like notepad, so when i minimize the notepad, or maximize, it must rest in my application. thank you
1
by: ace danger | last post by:
I have some javascript that works in Firefox 2 but not in IE 7. In the parent page, a user clicks a link and a new window is opened so that they can maintain some values. When the user is...
29
Frinavale
by: Frinavale | last post by:
I have 2 FireFox (version 2) browser windows opened. One is the child of the other. When the user is finished with the child window, a method in the parent window is called to refresh a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.