473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
2 19201
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dave | last post by:
I see this problem in IE but not Firefox. I have a page that opens a second page as a dialog box. If the Dialog is relaunched from a second instance on the page the Dialog window is reused, the...
2
by: Richard Bell | last post by:
I'm a bit new to Javascript and am trying to do oNewWin = window.open( ... ); then determine when the contents of oNewWin are completely loaded. I've tried oNewWin.attachEvent( "onload",...
6
by: news.versatel.de | last post by:
Hello NG, I am using javascript to open a new window like this: printpreview=window.open('printview.php','printprev','width=600,height=600'); The new window has a layer called preview: ...
4
by: Davey | last post by:
I have a website which has a popup window (this only opens when the user chooses to open it). In the popup window I have a <select> control which lists a selection of "classes". Each class has a...
2
by: Patient Guy | last post by:
I have a library of functions representing a filesystem interface (essentially a file selection interface, to be used in opening/reading/writing/closing files). Heavily scripted HTML document...
2
by: Raj | last post by:
Hi All, I have a problem with trying to refresh the parent window from child window in order to update data in the parent window. The sequence of events are 1) I click a button in the parent...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
4
by: John Kotuby | last post by:
Hello all, I am new to Javascript and have been trying to find an answer to this problem. After searching 3 books and searching postings, I am going to ask this newgroup. I am using a pre-built...
3
by: O.B. | last post by:
I have a form that shows another child form using the Show() operation. Since the child is modaless, I would like the option that when I click anywhere on the parent form that the parent form...
9
by: 200dogz | last post by:
Hi guys, I want to have a button which opens up a new window when pressed. <asp:Button ID="Button1" runat="server" Text="Open new window" /> ... Button1.Attributes.Add("OnClick",
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.