Child window calling a script loaded in parent...

Discussion in 'Javascript' started by Randell D., Mar 17, 2005.

  1. Randell D.

    Randell D. Guest

    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.
    Randell D., Mar 17, 2005
    #1
    1. Advertising

  2. Randell D.

    Randell D. Guest

    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
    Randell D., Mar 17, 2005
    #2
    1. Advertising

  3. Randell D.

    Arik Segal Guest

    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."
    <> 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.
    Arik Segal, Mar 22, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bhishm
    Replies:
    2
    Views:
    789
    bruce barker
    Sep 3, 2007
  2. Noel Dolan
    Replies:
    0
    Views:
    218
    Noel Dolan
    Jul 18, 2004
  3. Spammay Blockay
    Replies:
    1
    Views:
    402
    Dietmar Meier
    Feb 4, 2005
  4. Bhishm
    Replies:
    2
    Views:
    207
    Thomas 'PointedEars' Lahn
    Sep 4, 2007
  5. Bitswapper
    Replies:
    5
    Views:
    119
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page