G
Guest
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
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