Parent Docoument after window.open() - callBack-Access

R

Robert Degen

Hello,

I got a little problem. Seems very simple:

* I want to open a popup window
* Popup-window uses data from its father window.

BUT a parent.window does NOT point to the real parents window.
Alerting parent.window.location.href shows me, I'm at the wrong window
location.

So, how do I get back to my CREATOR window ? (If I am a popup).
By the time I can only fix it by....


1: ... // creation
2: var w = window.open("...", "...", "...");
3: w.parentWindow = window;


4: // child code
5: alert(window.parentWindow.location.href);



Works, IF child code is executed faster than line 3. Could be realised
with a refreshing timer bit would be anything BUT clean.

What I need is something that is initialized directly through
window.open-Call. I want something like:

4: // child code
5: alert(parent.location.href);

or

5: alert(window.parent.location.href);


Am I stupid ?

Please help :)

Regards
Rob
 
G

Gérard Talbot

Robert Degen wrote :
Hello,

I got a little problem. Seems very simple:

* I want to open a popup window
* Popup-window uses data from its father window.

BUT a parent.window does NOT point to the real parents window.
Alerting parent.window.location.href shows me, I'm at the wrong window
location.

So, how do I get back to my CREATOR window ? (If I am a popup).
By the time I can only fix it by....


1: ... // creation
2: var w = window.open("...", "...", "...");

The window object reference should be a global variable if you want
parent and child windows to "communicate", if you want the child window
data to populate the parent window. The window object reference *must*
be a global variable in order to achieve your goal.
3: w.parentWindow = window;

Where do you get this parentWindow property to begin with?
I understand what you're trying to do but you're trying to rewrite a
property (which is called opener) that should be read-only to begin
with. You shouldn't be "playing with" references like that.

4: // child code
5: alert(window.parentWindow.location.href);

parentWindow is not a reserved keyword.
Works, IF child code is executed faster than line 3.

That's because you are using MSIE 6 which had a bug to start with; that
same bug was fixed in MSIE 7 beta 2 after reporting that bug. So, your
code won't work in future releases.
Could be realised
with a refreshing timer bit would be anything BUT clean.

Window and document are created asynchronously.
What I need is something that is initialized directly through
window.open-Call. I want something like:

4: // child code
5: alert(parent.location.href);

or

5: alert(window.parent.location.href);

Gérard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top