detecting when a frame has loaded the result of a form submit

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Halldór Ísak Gylfason

    detecting when a frame has loaded the result of a form submit

    In my application I have an iframe that is empty (and not visible)
    initially, however when a user presses a button a form is
    programmaticall y submitted and the target is set to the IFrame.

    I want to detect when the frame has been loaded with the result of the
    form submit.

    Of course I have tried some event handlers like onload, onactivate,
    onreadystatecha nge, but they do not work in this example. They only
    seem to work, when the "SRC" attribute of the "IFrame" is set, e.g.
    not when the IFrame is set as the target of the form.

    Any ideas on how to do this?

    Regards, Halldor
  • Martin Honnen

    #2
    Re: detecting when a frame has loaded the result of a form submit



    Halldór Ísak Gylfason wrote:[color=blue]
    > In my application I have an iframe that is empty (and not visible)
    > initially, however when a user presses a button a form is
    > programmaticall y submitted and the target is set to the IFrame.
    >
    > I want to detect when the frame has been loaded with the result of the
    > form submit.
    >
    > Of course I have tried some event handlers like onload, onactivate,
    > onreadystatecha nge, but they do not work in this example. They only
    > seem to work, when the "SRC" attribute of the "IFrame" is set, e.g.
    > not when the IFrame is set as the target of the form.
    >
    > Any ideas on how to do this?[/color]

    With Netscape 7 and IE6 the following intially doesn't show the iframe
    and then shows it when the form is submitted

    <html>
    <head>
    <title>iframe onload handler</title>
    </head>
    <body>
    <form action="jsInter preter.html"
    target="frameNa me">
    <p>
    <input type="text" name="GOD" value="Kibo">
    <input type="submit">
    </p>
    </form>
    <p>
    <iframe name="frameName " style="display: none;"
    onload="if (typeof this.loadCount == 'undefined') {
    this.loadCount = 0;
    }
    this.loadCount+ +;
    if (this.loadCount > 1) {
    this.style.disp lay = '';
    }"></iframe>
    </p>
    </body>
    </html>

    Doesn't work with Opera 7 as that doesn't support
    <iframe onload
    thus if you need to have it work cross browser you are probably better
    off to use the onload handler of the page to which the form is submitted.
    However when I try the following as the containing page

    <html>
    <head>
    <title>iframe onload handler</title>
    </head>
    <body>
    <form action="test200 3091501.html"
    target="frameNa me">
    <p>
    <input type="text" name="GOD" value="Kibo">
    <input type="submit">
    </p>
    </form>
    <p>
    <iframe name="frameName " id="frameName" style="display: none;"></iframe>
    </p>
    </body>
    </html>

    and the following as the frame page

    <html>
    <head>
    <title>iframe load test</title>
    <script type="text/javascript">
    function showFrame () {
    if (window != parent) {
    if (document.getEl ementById) {
    var iframe = parent.document .getElementById (this.name);
    iframe.style.di splay = '';
    }
    }
    }
    </script>
    </head>
    <body onload="showFra me();">
    <p>
    iframe load test
    </p>
    </body>
    </html>

    then it still doesn't work with Opera 7 as that opens a new window to
    submit the form to, probably as the iframe with display: none is not
    considered a form target.
    When I change the containing page to

    <html>
    <head>
    <title>iframe onload handler</title>
    </head>
    <body>
    <form action="test200 3091501.html"
    target="frameNa me">
    <p>
    <input type="text" name="GOD" value="Kibo">
    <input type="submit">
    </p>
    </form>
    <p>
    <iframe name="frameName " id="frameName"
    style="visibili ty: hidden;"></iframe>
    </p>
    </body>
    </html>

    and the frame to

    <html>
    <head>
    <title>iframe load test</title>
    <script type="text/javascript">
    function showFrame () {
    if (window != parent) {
    if (document.getEl ementById) {
    var iframe = parent.document .getElementById (this.name);
    iframe.style.vi sibility = 'visible';
    }
    }
    }
    </script>
    </head>
    <body onload="showFra me();">
    <p>
    iframe load test
    </p>
    </body>
    </html>
    --

    Martin Honnen


    Comment

    • asdf asdf

      #3
      Re: detecting when a frame has loaded the result of a form submit

      The target of the form can return html containing some javascript that
      notifies your app of success or failure (provided they are in the same
      domain)

      Hope that helps

      Comment

      Working...