Child window calling a script loaded in parent...

R

Randell D.

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 IFRAME. I've got several
months of javascript under my belt and can resolve most things without
errors in my Mozilla Javascript Console, but this one just does not do
it for me.

This is the picture:

I have my 'parent' (main) window that contains a script - for test
purposes, its called myFunction(). It contains a simple hello world in
an alert call.

I have an IFRAME inside the parent. The IFRAME window is called winda2.

I want my IFRAME (thus, the child) to call myFunction from the parent
and my attempts thus far have failed.

From within my child window, I have done the following:

<script language="JavaScript" type="text/javascript">
window.opener.myFunction();
</script>

I've played with the above call and done variations of the above and get
the following messages in Mozilla Javascript Console:

Error: opener has no properties
Error: window.myFunction is not a function

and other similar type messages.

Can someone help point me in the right direction? It would be greatly
appreciated... please reply via the newsgroup so all can learn,

thanks
randell d.
 
R

Randell D.

Randell said:
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 IFRAME. I've got several
months of javascript under my belt and can resolve most things without
errors in my Mozilla Javascript Console, but this one just does not do
it for me.

This is the picture:

I have my 'parent' (main) window that contains a script - for test
purposes, its called myFunction(). It contains a simple hello world in
an alert call.

I have an IFRAME inside the parent. The IFRAME window is called winda2.

I want my IFRAME (thus, the child) to call myFunction from the parent
and my attempts thus far have failed.

From within my child window, I have done the following:

<script language="JavaScript" type="text/javascript">
window.opener.myFunction();
</script>

I've played with the above call and done variations of the above and get
the following messages in Mozilla Javascript Console:

Error: opener has no properties
Error: window.myFunction is not a function

and other similar type messages.

Can someone help point me in the right direction? It would be greatly
appreciated... please reply via the newsgroup so all can learn,

thanks
randell d.


Found it...

From inside my IFRAME, I call the script that is loaded in the parent
window using

top.myFunction();


randelld
 
A

Arik Segal

The Opener property will only work in floating windows. not in
iframes. Try using parent.myfunction() or top.myfunction()
 

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
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top