473,399 Members | 2,278 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,399 software developers and data experts.

Child window calling function in parent


Folks,

I was sure this could be done - or at least sure I had seen reference to
it at some point or other - but now, after having gone for a cup of tea,
am begining to doubt my original belief.

Can I have a script, available in a parent function, called from a child
window? If so, how?

And... if so, why? I mean, while sipping my tea, I realised that if the
child window had a <script src> tag calling a javascript file that was
already cached, then it would (in theory) be instantly available...

My attempts so far have revolved around trying object 'calls' like
top.document.functionName(arg1, arg2) but this has failed.

and... if I have a variable defined in a script file, loaded in the
parent window, how can I refer to it from the child window?

All help, via the newsgroup please, is much apprecaited, thanks
randelld
Jul 23 '05 #1
2 7851
On Sat, 03 Apr 2004 01:38:48 GMT, Reply Via Newsgroup
<re****************@please.com> wrote:
Can I have a script, available in a parent function, called from a child
window?
Assuming that the script in question has been loaded and parsed, yes.
If so, how?
Use the window.opener property to refer to the parent window. The use of
self, top, and parent relates to frames, not open windows.
And... if so, why? I mean, while sipping my tea, I realised that if the
child window had a <script src> tag calling a javascript file that was
already cached, then it would (in theory) be instantly available...
If cached, the file will be available. However, that doesn't mean that
it's been parsed, and it's functions and variables ready.

[snipped call with top]
and... if I have a variable defined in a script file, loaded in the
parent window, how can I refer to it from the child window?


Just as you would with frames, only using the window.opener property:

opener.myFunction();
opener.myVar = 'some value';

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #2
Michael Winter wrote:
On Sat, 03 Apr 2004 01:38:48 GMT, Reply Via Newsgroup
<re****************@please.com> wrote:
Can I have a script, available in a parent function, called from a
child window?

Assuming that the script in question has been loaded and parsed, yes.
If so, how?

Use the window.opener property to refer to the parent window. The use of
self, top, and parent relates to frames, not open windows.
And... if so, why? I mean, while sipping my tea, I realised that if
the child window had a <script src> tag calling a javascript file that
was already cached, then it would (in theory) be instantly available...

If cached, the file will be available. However, that doesn't mean that
it's been parsed, and it's functions and variables ready.

[snipped call with top]
and... if I have a variable defined in a script file, loaded in the
parent window, how can I refer to it from the child window?

Just as you would with frames, only using the window.opener property:

opener.myFunction();
opener.myVar = 'some value';

Mike

Thanks - My javascript skills are getting better and better - clear
answers like what you've offered above that I've got from this newsgroup
over the past months deserve alot of credit.

Cheers,
Randell D.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bostonasian | last post by:
I am trying to append options to dropdown in parent window from option items in child window. In parent window, I have following code: <script language="javascript"> function...
2
by: Randell D. | last post by:
Folks, I have got this working before, in part with some help from this ng but I never really understood how I got it working... and last time, I was using it via a popup window as opposed to an...
1
by: Bill Borg | last post by:
Hello all, Simple chat app, where the site owner has a master window with all requests for chat, status of each room, etc., and child windows for each separate chat in which the owner is...
1
by: jd | last post by:
Hi guys, I'm trying to create an HTML page that contains two frames. The bottom frame should simply be some website, but the top frame needs to have a close link to kill the window. I tried calling...
1
by: Bhishm | last post by:
Hi, I am opening a child window from parent using window.open, but on refreshing the parent the reference of the child is lost. Is there any way to save the reference of the child in the...
5
by: Nithu25 | last post by:
Hi All, I have a parent window where i have three links. On clicking those links, new window will be opened as a pop up. When i logout from the parent window, the child windows should be closed....
1
by: nupuragr82 | last post by:
I have a parent form and on button click I am calling a child page where i have a textbox and a button. On button click of child form I am passing the value of the Textbox to the Textbox in parent...
4
by: Buddha | last post by:
Hello, I posted this on two forums, without too much help .. and I am kinda stuck in this. I need to refresh the parent page from the second child window which is opened by the first child and...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.