Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > 2nd call from child window to parent fails

Reply
Thread Tools

2nd call from child window to parent fails

 
 
=?Utf-8?B?QmlsbCBCb3Jn?=
Guest
Posts: n/a
 
      06-06-2005
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmlsbCBCb3Jn?=
Guest
Posts: n/a
 
      06-06-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If a class Child inherits from Parent, how to implementChild.some_method if Parent.some_method() returns Parent instance ? metal Python 8 10-30-2009 10:31 AM
Call javascript in parent from child (pop up) window ace danger Javascript 1 01-12-2007 06:29 PM
Results from child window submit into parent window, then child closes -- How To? Spammay Blockay Javascript 1 02-04-2005 12:47 PM
Pass from parent to child, then update parent with child value... Noel Dolan Javascript 0 07-18-2004 05:52 PM
call a parent javascript function from the child window Filiz Duman Javascript 1 01-21-2004 03:30 PM



Advertisments