By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,223 Members | 1,434 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,223 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Mar 17 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Solved!

// child code
alert(window.opener.location.href);

....

I love JS...

Robert Degen schrieb:
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

Mar 17 '06 #2

P: n/a
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
--
remove blah to email me
Mar 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.