Child window calling a script loaded in parent...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Randell D.

    #1

    Child window calling a script loaded in parent...


    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="JavaS cript" type="text/javascript">
    window.opener.m yFunction();
    </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.myFuncti on 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.

    #2
    Re: Child window calling a script loaded in parent...

    Randell D. wrote:[color=blue]
    >
    > 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="JavaS cript" type="text/javascript">
    > window.opener.m yFunction();
    > </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.myFuncti on 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.[/color]


    Found it...

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

    top.myFunction( );


    randelld

    Comment

    • Arik Segal

      #3
      Re: Child window calling a script loaded in parent...

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

      --
      Arik Segal
      Tel-Aviv

      On Thu, 17 Mar 2005 08:07:06 GMT, "Randell D."
      <reply.via.news group.thanks@fi projects.moc> wrote:
      [color=blue]
      >
      >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="JavaS cript" type="text/javascript">
      > window.opener.m yFunction();
      ></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.myFuncti on 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.[/color]

      Comment

      Working...