Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tough question: accessing the parent of a window opener

51 views
Skip to first unread message

Zeba Kimmel

unread,
Aug 28, 1998, 3:00:00 AM8/28/98
to
Here's a tough question! My main browser window has two frames, call them A
and B. From A, I open up a new window. I want that new window to access not
only A, but also A's parent (the main browser window frameset) and B--in
particular, to change B's location. How can I do it?

The following script in the new window:

<script>
document.write("<BR>opener property is " + window.opener.name);
document.write("<BR>opener property is " + window.opener.parent);
document.write("<BR>opener property is " + window.opener.parent.name);
</script>

prints out:

opener property is menu
opener property is [object]
opener property is

So I can get to the parent, but I can't access any of its properties, it
seems.

I've looked throughout the netscape & microsoft on-line documentation, but
can't find any solution there.

Thanks in advance,

--Zeba Kimmel, z-ki...@uiuc.du

Kevin

unread,
Aug 28, 1998, 3:00:00 AM8/28/98
to

Zeba Kimmel wrote:

> Here's a tough question! My main browser window has two frames, call them A
> and B. From A, I open up a new window. I want that new window to access not
> only A, but also A's parent (the main browser window frameset) and B--in
> particular, to change B's location. How can I do it?

You would have an easier time if you put the window.open() function in the top
frameset and call it from A. That would make the child a of sibling of A and B
and then you could reference them all as properties of window.opener

Then from child of A:

top is window.opener
The main window should be top
A is top.A or top.frames[0]
B is top.B or top.frames[1]

Tested on Netscape 4.06

--
Hope this helps,
Kevin
------------------------------------------
Kevin Brown
Design Staff Manager

MYERS INTERNET SERVICES
http://www.myer.com/

Kevin

unread,
Aug 28, 1998, 3:00:00 AM8/28/98
to
Sorry, I'm working too quickly. See adjustments below...

Kevin wrote:

>
> You would have an easier time if you put the window.open() function in the top
> frameset and call it from A. That would make the child a of sibling of A and B
> and then you could reference them all as properties of window.opener
>
> Then from child of A:
>

> The main window should be window.opener
> A is window.opener.A or window.opener.frames[0]
> B is window.opener.B or window.opener.frames[1]

The location of B would then be
window.opener.B.location.href

Prize Productions

unread,
Aug 28, 1998, 3:00:00 AM8/28/98
to
could you put up a sample of this somewhere please and email me the url? I
would greatly appreciate this as I have been asked this question many times
and have had no answer.

...Laurie


Kevin wrote in message ...

Zeba Kimmel

unread,
Aug 28, 1998, 3:00:00 AM8/28/98
to
>> You would have an easier time if you put the window.open() function in
the top
>> frameset and call it from A. That would make the child a of sibling of A
and B
>> and then you could reference them all as properties of window.opener


It is sort of working. But whenever I resize the new window, it seems to
forget who its parent is (in Netscape; everything seems to work properly in
IE) and I lose all the frame references. Is there any workaround? I want the
new window to be resizable.

Thanks!


Zeba Kimmel

unread,
Aug 28, 1998, 3:00:00 AM8/28/98
to
Prize Productions wrote in message <6s7gtt$u98$1...@stalker.oem.net>...

>could you put up a sample of this somewhere please and email me the url? I
>would greatly appreciate this as I have been asked this question many times
>and have had no answer.


I've been working on it for a full day now and still don't have it working
quite right. Both browsers keep crashing, too, because they are so darn
unstable. Where is the GNU browser we all need?

Zeba


Kevin

unread,
Aug 30, 1998, 3:00:00 AM8/30/98
to

Zeba Kimmel wrote:

> I've been working on it for a full day now and still don't have it working
> quite right. Both browsers keep crashing, too, because they are so darn
> unstable.

My observation has been that any window launching and framed page development is
prone to this kind of crashing. Remember that each frame is a window object,
which counts as a browser. On my NT box, depending on the length of the browser
history, each window has showed up being as much as 5-7MB each.

It seems understandable that constantly opening and closing windows and
reloading frames will crash your browser more frequently in development, but
this is because you find yourself reloading and launching windows a *heck* of a
lot more than a user will when they actually hit your site in a real world
scenario.

Kevin

unread,
Aug 30, 1998, 3:00:00 AM8/30/98
to
Zeba Kimmel wrote:

> It is sort of working. But whenever I resize the new window, it seems to
> forget who its parent is (in Netscape; everything seems to work properly in
> IE) and I lose all the frame references. Is there any workaround? I want the
> new window to be resizable.

I have not found a workaround. Reloading is just that, reloading; from the
beginning. You lose all your object references created by your scripts. If you
learn anything new, please post it.

Zeba Kimmel

unread,
Aug 30, 1998, 3:00:00 AM8/30/98
to
OK, I got it working. Mostly. In my top-level HTML file, where I define the
frames, I have:
------------------------
<head>
<script>

function isMicrosoftBrowser()
{
return navigator.appName.indexOf('Microsoft') != -1;
}

function openNewWindow()
{
if (!isMicrosoftBrowser())
return window.open('name.html','othername','dependent=yes,scrollbars=yes,resizable=no,innerWidth=300,innerHeight=300');
else
return window.open('name.html','othername','dependent=yes,scrollbars=yes,resizable=yes, height=300, width=300');
}
</script>
</head>

<frameset>
<frame src="bam.html" name="childframe" >
<frame src="pow.html" name="alsochildframe" >
</frameset>


------------------------
The reason for two code segments is that IE does not forget its opener when it resizes, but Communicator does. So I don't let the user resize a Communicator window.

Now, when I want a frame to open a new window, I put something like this in the frame.
------------------------
<input type="button" name="blah" value="blargh" onClick="windowname=parent.openNewWindow();" >
------------------------
And in the new window that opens up (inside the 'name.html' file) I put:
------------------------
<script>
function influenceParentFrame(value)
{
parent.opener.value=value;
parent.opener.childframe.location='somefile.html';
}
</script>
------------------------
This way I can send back information to frames (eg 'childframe') in the opener. For example, 'somefile.html' (which appears in frame 'childframe') can look up 'value' in its parent window.

If you think this is really complicated and a pain and there must be a better way to do it: I agree!

--Zeba Kimmel, z-ki...@uiuc.edu

P.S. A new problem that crops up is that the main browser window in IE seems unable to close the new window properly after a little while--it seems to lose all saved references--but Communicator can. I haven't figured out why.


Kevin

unread,
Aug 30, 1998, 3:00:00 AM8/30/98
to
Kevin wrote:

> Zeba Kimmel wrote:
>
> > I've been working on it for a full day now and still don't have it
> working
> > quite right. Both browsers keep crashing, too, because they are so
> darn
> > unstable.
>
> My observation has been that any window launching and framed page
> development is
> prone to this kind of crashing. Remember that each frame is a window
> object,
> which counts as a browser. On my NT box, depending on the length of
> the browser
> history, each window has showed up being as much as 5-7MB each.
>
> It seems understandable that constantly opening and closing windows
> and
> reloading frames will crash your browser more frequently in
> development, but
> this is because you find yourself reloading and launching windows a
> *heck* of a
> lot more than a user will when they actually hit your site in a real
> world
> scenario.

Found a little more info:"Communicator allows a maximum of 100 windows
to be around at once. If
you open window2 from window1 and then are done with window1, be
sure to set the opener property of window2 to null. This allows
JavaScript to garbage collect window1. If you do not set the opener
property to null, the window1 object remains, even though it's no longer

really needed."

From
http://developer.netscape.com/docs/manuals/communicator/jsref/win1.htm#1152528

0 new messages