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

Child window calling a script loaded in parent...

P: n/a

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.
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Randell D. wrote:

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
Jul 23 '05 #2

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

--
Arik Segal
Tel-Aviv

On Thu, 17 Mar 2005 08:07:06 GMT, "Randell D."
<re************************@fiprojects.moc> wrote:

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.


Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.