Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts

    Submitting in another frame

    I have a main page and an iframe. I want to click a link on the main page, which submits a form contained in the iframe. This works in IE, but not Firefox. I don't receive any errors but it just ignores the form.submit() call.

    Another note, it works in Firefox if I haven't called any other javascript functions prior to submitting.

    mainpage.htm
    Code:
    <script language="javascript">
    function saveItAll(){
      document.forms[0].submit();
    }
    </script>
    
    <a href="#" onclick="frames['MyIframe'].saveItAll()">
    iframe.htm
    Code:
    <form name="test" action="process.php" method="post">
    <input type="text" name="test1" id="test1">
    </form>

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    I don't know why that works in IE. Based on your description, the code should be something like this:

    mainpage.htm
    Code:
    <a href="#" onclick="window.frames['MyIframe'].saveItAll(); return false;">Submit</a>
    <iframe name="MyIframe" src="iframe.htm"></iframe>
    iframe.htm
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function saveItAll(){
      document.forms[0].submit();
    }
    </script>
    </head>
    <body>
    <form name="test" action="process.php" method="post">
    <input type="text" name="test1" id="test1">
    </form>
    </body>
    </html>

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Alright, thank you for the attempt. It doesn't seem to work though. I can do something as simple as:

    alert(a);
    myform.submit();
    alert(b);

    And it will actually display "a" and "b" but it won't submit the form. I've limited it down to a Firefox bug so I will submit it to them.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •