call function in iframe

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christian Radermacher

    call function in iframe

    I have document with an iframe in it. I'm able to call a javascript
    function in the main-document from the javascript inside the
    iframe-document. I have difficulties to do the other way round, i.e. to
    call a function in the iframe-document from javascript in the main-document.


    TIA

    Christian

  • Janwillem Borleffs

    #2
    Re: call function in iframe


    "Christian Radermacher" <rader@inwind.i t> schreef in bericht
    news:C94Za.3395 7$an6.1189963@n ews1.tin.it...[color=blue]
    > I have document with an iframe in it. I'm able to call a javascript
    > function in the main-document from the javascript inside the
    > iframe-document. I have difficulties to do the other way round, i.e. to
    > call a function in the iframe-document from javascript in the[/color]
    main-document.[color=blue]
    >
    >[/color]

    The following works with IE, Opera 7 and Mozilla when both pages are hosted
    on the same domain/environment:

    d = document;
    f = d.frames ? d.frames['frameName'] : d.getElementByI d('frameId');
    p = f.document || f.contentWindow .document;

    p.functionName( );


    JW



    Comment

    • Martin Honnen

      #3
      Re: call function in iframe



      Christian Radermacher wrote:[color=blue]
      > I have document with an iframe in it. I'm able to call a javascript
      > function in the main-document from the javascript inside the
      > iframe-document. I have difficulties to do the other way round, i.e. to
      > call a function in the iframe-document from javascript in the
      > main-document.[/color]

      Use
      <iframe name="iframeNam e"
      and then
      if (window.frames. iframeName && window.frames.i frameName.funct ionName) {
      window.frames.i frameName.funct ionName();
      }




      --

      Martin Honnen


      Comment

      • Martin Honnen

        #4
        Re: call function in iframe



        Christian Radermacher wrote:[color=blue]
        > I have document with an iframe in it. I'm able to call a javascript
        > function in the main-document from the javascript inside the
        > iframe-document. I have difficulties to do the other way round, i.e. to
        > call a function in the iframe-document from javascript in the
        > main-document.[/color]

        Use
        <iframe name="iframeNam e"
        and then
        if (window.frames. iframeName && window.frames.i frameName.funct ionName) {
        window.frames.i frameName.funct ionName();
        }




        --

        Martin Honnen


        Comment

        • nec

          #5
          Re: call function in iframe

          I've got the same problem as Christian..

          When i use the functioncall window.frames.c ontens.alerter( 'dsa') (in then
          iFrame called contens, and the function called alerter) i get this message
          in the FireFox Javascript Console:

          Error: window.frames.c ontens has no properties

          The script wors fine in IE (or rather: a variant of it) som the frame name
          and fuction is right.

          How was it solved?


          Comment

          • Ranbir Kaur

            #6
            Re: call function in iframe

            Hi,

            In article
            <aae3e5e080f73f 498b34d60d4f99b 4a6@localhost.t alkaboutprogram ming.com>, Nec
            wrote:
            [color=blue]
            > When i use the functioncall window.frames.c ontens.alerter( 'dsa') (in then
            > iFrame called contens, and the function called alerter) i get this message
            > in the FireFox Javascript Console:
            >
            > Error: window.frames.c ontens has no properties
            >
            > The script wors fine in IE (or rather: a variant of it) som the frame name
            > and fuction is right.[/color]

            The parent page of the IFrame needs to contain the functions called by a
            page loaded into the IFrame.

            I hope it helps,

            Ranbir


            Comment

            Working...