Forum Moderators: open

Message Too Old, No Replies

Changing the original window's frameset from a frame in a pop-up window

window.opener not working

         

Markie

12:34 pm on Sep 2, 2002 (gmt 0)



I have a problem with the window.opener function in Javascript.

My first page "frames.htm" has two frames, see below

***************
*
* frame1.htm
*
***************
*
* frame2.htm
*
***************

The code of frame2.htm looks like this:

<html>
<head>
<title>Hallo</title>
<script>
window.open("test.htm", "plugin");
</script>
</head>
<body>
</body>
</html>

Now test.htm is opened and this page also has two frames, see below.

***************
*
* ftest1.htm
*
**************
*
* ftest2.htm
*
**************

Now I want to change the page "frames.htm" in "change.htm" from the file "ftest2.htm".

How can I do that? The window.opener function does not work here. It works fine if I use the window.opener function in test.htm. But thats not an option.

Please advise asap!

Thanx

joshie76

1:43 pm on Sep 2, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Markie,

Crikey, thats a lot o' frames. I've reread your message a number of times but I can't work out where change.htm fits into the picture.

Josh

BlobFisk

2:03 pm on Sep 2, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm also a bit confused with all these frames.... but how about target="_top"?

dhdweb

3:17 pm on Sep 2, 2002 (gmt 0)

10+ Year Member



Why do you need frames in the first place.

Anyway, why not set all the frames on one frameset instead of having a frame load a page with frames and so on?

Your current method is just asking for headaches!

rewboss

7:07 pm on Sep 2, 2002 (gmt 0)

10+ Year Member



First, to address the window which opened the popup, you need the opener property of the parent window of the current frame. (Remember, window.open opened the frameset, not the individual frame.) This would be:

parent.opener

Since the window.open() function was in frame2.htm, and you want to change the URL of the frameset, you need to address the parent window of parent.opener, like this:

parent.opener.parent

Finally, you need to address the Location object of that window:

parent.opener.parent.location

So the code you require is:

parent.opener.parent.location='change.htm';

Once again: That is the Location object of the parent window of the current frame's parent's opener. Easy, huh?

(Argh... I think I was better off trying to learn irregular Russian verbs...)

Markie

6:06 am on Sep 3, 2002 (gmt 0)



Thanks for all your help. The solution was very simple after all!