Iframe submit issue in Firefox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CAG
    New Member
    • Oct 2006
    • 4

    Iframe submit issue in Firefox

    Hello,

    I have following scenario in my web application.
    I want to load different web forms in single iframe. Iframe in contained in an ASP page. ASP page has “Submit” button, which submits iframe form, & then load new form in same frame.

    This is more like slide show of child forms. ASP button also has “Back” button which loads previously submitted form in same iframe. On click of “submit” button, it resubmits child form.

    This works fine in IE 6. But in firefox “re-submission” of form does not take place. So that in firefox, child form gets submitted only once.


    Sample code

    [CODE=javascript]function setURL(form_url )
    {
    var iframe = “<iframe id= iframe name= “ + form_label + “ src= ” + form_url;
    document.getEle mentById(“div_n ame”).innerHTML = iframe;
    }

    function submitForm()
    {
    var frameObj = window.frames.f orm_label;
    if(frameObj.doc ument.childForm )
    {
    frameObj.docume nt.childForm.su bmit();
    setURL(nextForm _url);
    }
    }[/CODE]


    above if condition fails in firefox when same child form(i.e with form_label value) is reloaded in iframe. Same code works fine in IE.

    Thanks in advanced.
    Last edited by gits; Jul 19 '07, 07:32 AM. Reason: added CODE-tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    hi ...

    you posted into the articles-section rather then in the forum ... i moved it across for you ... so that the experts may find and answer it ...

    kind regards

    Comment

    • Simon88
      New Member
      • Oct 2007
      • 1

      #3
      I have a very similar problem, i think this is an Firefox bug. I have posted it an i am waiting for an answer...

      We have the next situation:
      - page with an iframe.
      - the iframe contents a function called f().

      We want to load the iframe and execute a function inside iframe from outside iframe.


      We follow the next steps:

      Step 1 - Button "load div_content": Ok.

      Step 2 - Execute function f()
      Execute function from inside iframe: Ok.
      Execute function from outside iframe: Ok.

      Step 3 - View location.href of iframe: Ok.
      From inside: Ok.
      From outside: Ok.

      And we go to the beginning:

      Step 1 - Reload div_content: Ok.

      Step 2 - Execute function f()
      Execute function from inside iframe: Ok.
      Execute function from outside iframe: ERROR.

      Step 3 - View location.href of iframe
      From inside: Ok.
      From outside: ERROR.


      The second time we load the div_content with the same code, the function f() inside iframe is not accessible.

      If we load the div_content with the same code changing the name of iframe (idFrame, idFrame2, idFrame3,...) the first load works fine, but if we reload an ancient iframe the function inside iframe is not accessible.

      Init.html
      -----------------------------------------------------------------------------
      [HTML]<html>
      <head>
      <title>Init</title>
      </head>
      <body>
      <input type="button" value="Step 1- load div_content" onClick="docume nt.getElementBy Id('div_content ').innerHTML='< iframe id=\'idFrame\' name=\'idFrame\ ' src=\'iframe.ht ml\' ></iframe>'" ><br>
      <input type="button" value="Step 2 - execute function f() inside iframe" onClick="window .frames['idFrame'].f()" ><br>
      <input type="button" value="Step 3 - view location " onClick="alert( window.frames['idFrame'].location.href) ;" ><br>
      <div id="div_content ">
      </div>
      </body>
      </html>[/HTML]


      iframe.html
      -----------------------------------------------------------------------------
      [HTML]<html>
      <head>
      <title>Iframe </title>
      <script type="text/javascript">
      function f()
      {
      alert('Fucntion f().');
      }
      </script>
      </head>
      <body>
      <input type="button" value="Step 2 - execute function f() inside iframe" onClick="f()" >
      <input type="button" value="Step 3 - view location" onClick="alert( self.location)" >
      </body>
      </html>[/HTML]
      Last edited by gits; Oct 8 '07, 01:03 PM. Reason: added code tags

      Comment

      • CAG
        New Member
        • Oct 2006
        • 4

        #4
        Originally posted by Simon88
        I have a very similar problem, i think this is an Firefox bug. I have posted it an i am waiting for an answer...

        We have the next situation:
        - page with an iframe.
        - the iframe contents a function called f().

        We want to load the iframe and execute a function inside iframe from outside iframe.


        We follow the next steps:

        Step 1 - Button "load div_content": Ok.

        Step 2 - Execute function f()
        Execute function from inside iframe: Ok.
        Execute function from outside iframe: Ok.

        Step 3 - View location.href of iframe: Ok.
        From inside: Ok.
        From outside: Ok.

        And we go to the beginning:

        Step 1 - Reload div_content: Ok.

        Step 2 - Execute function f()
        Execute function from inside iframe: Ok.
        Execute function from outside iframe: ERROR.

        Step 3 - View location.href of iframe
        From inside: Ok.
        From outside: ERROR.


        The second time we load the div_content with the same code, the function f() inside iframe is not accessible.

        If we load the div_content with the same code changing the name of iframe (idFrame, idFrame2, idFrame3,...) the first load works fine, but if we reload an ancient iframe the function inside iframe is not accessible.

        Init.html
        -----------------------------------------------------------------------------
        [HTML]<html>
        <head>
        <title>Init</title>
        </head>
        <body>
        <input type="button" value="Step 1- load div_content" onClick="docume nt.getElementBy Id('div_content ').innerHTML='< iframe id=\'idFrame\' name=\'idFrame\ ' src=\'iframe.ht ml\' ></iframe>'" ><br>
        <input type="button" value="Step 2 - execute function f() inside iframe" onClick="window .frames['idFrame'].f()" ><br>
        <input type="button" value="Step 3 - view location " onClick="alert( window.frames['idFrame'].location.href) ;" ><br>
        <div id="div_content ">
        </div>
        </body>
        </html>[/HTML]


        iframe.html
        -----------------------------------------------------------------------------
        [HTML]<html>
        <head>
        <title>Iframe </title>
        <script type="text/javascript">
        function f()
        {
        alert('Fucntion f().');
        }
        </script>
        </head>
        <body>
        <input type="button" value="Step 2 - execute function f() inside iframe" onClick="f()" >
        <input type="button" value="Step 3 - view location" onClick="alert( self.location)" >
        </body>
        </html>[/HTML]

        I got solution to my problem,

        In my case I need to gave unique name to iframe each time.

        With this dynamically given name I'm able to access the form loaded in iframe each time.

        Thanks for support. :)

        Comment

        Working...