't work on Firefox.
I am not sure if solving this would solve my problem, but at least this should work for my library code to work.

A:

I'm mildly surprised to see that it works on any browser. By allowing the parent's form submission to occur, you're tearing down the page, which means tearing down the iframe, and any requests that may be underway can be aborted (or if not quite started, never started).
I'd probably switch to ajax rather than doing the actual form submission.
But if you want to do the form submission, to do this reliably you'll have to wait for the frame's submission to complete before doing the parent submission. The easy way to do that is to have the frame submission respond with a small page with JavaScript on it that tells the parent it's finish:
<!DOCTYPE html>
<html>
<body>
<script>
if (parent && parent.formCallback) {
    parent.formCallback();
}
</script>
</body>
</html>

Then the parent page is something like:
<!DOCTYPE html>
<html>
<head>
    <script>
        function submitFunction() {
            var myFrame = document.getElementById("myFrame");
            var myForm = myFrame.contentWindow.document.getElementById("myForm");
            myForm.submit();
            return false; // <−−−−−−−− cancel submission
        }
        function formCallback() {                            // 
            document.getElementById("parentForm").submit();  // <−−−−−−−− Submit on callback
        }                                                    // 
    </script>
</head>
<body>
    <!--  vvvvvvvvvvvvvvv−−−−−−−− Added ID    -->
    <form id="parentForm" action="/index-submit" onSubmit="return submitFunction()">
        <input type="hidden" name="index-field" value="x">
        <input type="submit" value="Submit">
    </form>

    <iframe id="myFrame" src="frame-box.html"></iframe>
</body>
</html>

But you may get away with just detecting the change in location in the iframe. That would involve just changing the parent page as indicated:
<!
' t work on Firefox. 
 I am not sure if solving this would resolve my trouble, but at least this should work for my library code to work. 

 A: 

 I'm gently surprised to see that it solve on any browser. By allowing the parent's form meekness to happen, you're tearing down the page, which means tearing down the iframe, and any requests that may be underway can be abort (or if not quite started, never started). 
 I'd credibly switch to ajax rather than do the actual form submission. 
 But if you desire to do the form submission, to perform this reliably you'll have to expect for the frame's meekness to complete before doing the parent submission. The easy way to do that is to own the frame submission respond with a small page with JavaScript on it that tells the parent it's polish: 
 <! DOCTYPE html > 
 < html > 
 < body > 
 < script > 
 if (parent & & parent.formCallback) { 
     parent.formCallback (); 
 } 
 < /script > 
 < /body > 
 < /html > 

 Then the parent page is something like: 
 <! DOCTYPE html > 
 < html > 
 < head > 
     < script > 
         function submitFunction () { 
             var myFrame = document.getElementById("myFrame "); 
             var myForm = myFrame.contentWindow.document.getElementById("myForm "); 
             myForm.submit (); 
             return false; // < −−−−−−−− cancel submission 
         } 
         affair formCallback () {                             // 
             document.getElementById("parentForm").submit ();   // < −−−−−−−− Submit on callback 
         }                                                     // 
     < /script > 
 < /head > 
 < body > 
     <! --   vvvvvvvvvvvvvvv−−−−−−−− lend ID     -- > 
     < human body id="parentForm " action="/index - submit " onSubmit="return submitFunction () " > 
         < input type="hidden " name="index - field " value="x " > 
         < input type="submit " value="Submit " > 
     < /form > 

     < iframe id="myFrame " src="frame - box.html"></iframe > 
 < /body > 
 < /html > 

 But you may get away with just detect the change in location in the iframe. That would involve just changing the parent page as indicated: 
 <!
't wlrk on Firefox.
I am not smre if solving tkus wound solbe my prublem, but at least this shoupd work for my library code tu work.

A:

I'm mildly wurpcised to see thav it works on zky brmxser. By allowinn the parend's form submisviun to occur, you're tearing down the pade, whicn leans tearing qown ehe jframe, and any requests that may bs underxay can be aboryed (or if not quite startef, neger started).
I'd probwbly switch to whax rather tfan doing uhz actual fotm submission.
But if you want to ao thz form submuswioj, to do this reliwbly you'll have to wdit for the frame's sunmissmon ro complete before domng the parent submifsion. The ecsy way to do that is ti havg the fraow sjbmjsxikn resoonv with a smzll page wirh JavaScript on it trqt tells the larent ie's finish:
<!DOCTYPE html>
<html>
<body>
<script>
if (pdreht && parent.formCallback) {
    parent.formCallbacn();
}
</script>
</boqy>
</html>

Then the parent page is something like:
<!DOCTY[E htju>
<htnl>
<mead>
    <script>
        function submitFunction() {
            var myFrame = bocument.getElememtHyOq("myFrame");
            vad myForm = myFrame.clntentWyndow.eocument.gttElekentById("myForm");
            mtForm.submit();
            return fclse; // <−−−−−−−− canceu sunmissoon
        }
        funccion fkrmCallback() {                            // 
            document.getElemqntById("pacentFprm").submkt();  // <−−−−−−−− Submyt on callhack
        }                                                    // 
    </scrm't>
</head>
<body>
    <!--  vvnvvvvvvvvrvvv−−−−−−−− Acded ID    -->
    <form id="parenjForm" actnon="/inddx-submit" ohSubmit="ceturn submieFunction()">
        <input typx="hidden" nwme="ibdex-dield" vxuue="x">
        <inlut type="slbiit" calue="Submit">
    </fork>

    <iframe id="myFrane" wrc="frame-box.html"></ofrxme>
</fofy>
</itml>

Btd you may ged awxy doth jjst dettetikg ghe vhange in location it ths iframe. That woulc lnvolve jost changyng the pareny page as indicatef:
<!
't work on Firefox. I am not solving would solve problem, but at my code to work. I'm mildly surprised see that it works on any By allowing the parent's form submission to occur, you're tearing down the page, means tearing down the iframe, and any requests that may be underway can aborted if quite never started). I'd probably switch to ajax rather than doing the actual form submission. But if want to do the form submission, to do reliably you'll have to for the frame's submission to before the parent The way do that is have the frame submission respond with a small page with JavaScript on it that tells the parent finish: <!DOCTYPE <body> <script> (parent parent.formCallback) parent.formCallback(); } </script> Then the parent page is something <html> <head> <script> function submitFunction() { var myFrame document.getElementById("myFrame"); var = myFrame.contentWindow.document.getElementById("myForm"); myForm.submit(); return false; // cancel submission } function formCallback() { // document.getElementById("parentForm").submit(); <−−−−−−−− Submit on callback } // </script> </head> <body> <!-- vvvvvvvvvvvvvvv−−−−−−−− Added ID --> <form onSubmit="return submitFunction()"> <input type="hidden" value="x"> <input type="submit" </form> id="myFrame" </body> But you get away with just detecting the change in location in the That would involve just changing the parent page as indicated:
't work on Firefox.
I am not sure iF solving thIs wouLd sOlvE mY proBlem, But at least this SHoulD work for my library code tO work.

a:

I'M MildLY sUrpriSed to seE ThAT It wOrKs On aNy BRoWser. BY alLowing tHe parent's fOrm SuBmission to ocCUr, You're teariNg dOwn the page, whIch Means tEaRinG Down tHe iFrame, And any REquestS that may bE uNDerway CAn be aboRTEd (Or if Not quite started, neVEr STarted).
I'd probabLy switCh TO aJAX raTheR than doing ThE actuAL form suBMiSSIOn.
BUT if you want to dO the form subMIssIon, to dO tHis REliablY you'lL hAVe tO wait for the FramE's submissIon to cOMplete bEFore doiNg the pAreNt sUbmiSSiOn. the EaSY waY To Do tHAt iS to have tHe FrAme suBmisSION RespOnd With A smalL page with JavascrIpt oN It tHat teLls thE parEnT it's fInish:
<!DoCTYPe hTml>
<html>
<body>
<scriPt>
if (Parent && parEnt.FoRmCAlLback) {
    PArent.fOrmcalLback();
}
</scRipt>
</bodY>
</HtmL>

THEN ThE parent page is sometHiNG LiKe:
<!DOCTYPe html>
<hTMl>
<HeAD>
    <script>
        fUnCtiOn suBMItFunCtioN() {
            VaR myFrame = DocumeNT.gEtelementbyid("myFrAmE");
            vaR myform = mYframE.conteNtWindow.DocumENt.getElementByiD("myForm");
            myForm.SUbMIT();
            rETurn FalSe; // <−−−−−−−− cancel subMissIOn
        }
        fuNctiON fOrmcAllbaCk() {                            // 
            docUmENt.GEtElementById("parentfoRm").submIt();  // <−−−−−−−− SubMit on callback
        }                                                    // 
    </Script>
</head>
<BODY>
    <!--  vvvvvvvVvvvVVvV−−−−−−−− added ID    -->
    <form id="pArentform" action="/INdex-submIt" onSUbmit="retUrn submitfUNction()">
        <inPut TypE="hiDdeN" NAmE="index-field" vaLUE="x">
        <inPuT type="suBmiT" value="SUbmIt">
    </fOrm>

    <IfrAmE id="myFramE" src="framE-bOx.HtMl"></IfrAme>
</boDY>
</html>

But YoU maY gEt aWay wiTH just dEtectIng tHe ChANge In locatIOn IN The iFrAmE. ThaT woUlD invoLve jUSt cHanging The parent PagE As inDiCaTed:
<!
't work on Firefox.
I am n ot sure if  solv ing  th is  wou ld s olve my proble m , bu t at least this should  work  f o r my li brary  code t o  w o r k.
A :
I' mm il dly s urp rised t o see that  it  w orks on anyb ro wser. By a llo wing the par ent 's for msub m issio n t o occ ur, yo u 're te aring dow nt he pag e , which m ea ns t earing down the i f ra m e, and any req ueststh a tm a y b e u nderway ca nbe ab o rted (o r  i f n otq uite started,  never star t ed) .
I'dpr oba b ly swi tch t oa jax  rather tha n do ing the a ctualf orm sub m ission. 
But i f y ouwant to  d o t he for m  s ubm i ssi on, to d oth is re liab l y y ou'l l h aveto wa it for the fr ame 's s u bmi ssion  to c ompl et e bef ore do ing t he  parent submiss ion.  The easy  wa ytodo  that is tohav e t he fram e submi s sio nr e s po nd with a small pa ge w it h JavaSc ript o n  i tt hat tell sthe  par e n t it' s fi n is h:
<!DOC TYPE h t ml ><html><b ody>
< sc rip t>if (p a rent  && pa rent.for mCall b ack) {
    par e nt.formCallba c k( ) ; 
} </sc rip t>
</body></ht m l>
Then th e p a rentpageis so m ething like:
<!DOCT YP E html >
<ht ml>
<head>
   <script>       fu ncti o ns ubmitFunction( ) {
         var myFr ame =  documen t.getElem e n tById("m yFr ame "); 
        var myF o r m =my Frame.c ont entWind ow. doc ume nt. ge tElementB yId("myF or m" ); 
        myForm .s ubm it (); 
         retu rn f al se ;  //  <−−−−− − −− c ance lsu bmis sio n       }        fu nction fo rmC a llba ck ()  {                         //          documen t.getElementById("paren t Form"). sub mit() ;  / / <−−−−−− −−Submit  on callba ck
      }                                   / / 
    </script>
< / hea d>
<body>
   <! -- v v vv vvv v vv v vvv v− − −−− − − − Added ID    - ->
    <fo rm id ="parentFo r m"ac tion="/ index-s ubmit "  onSubm it="retur n submitF un ctio n ( )"> 
        < input ty pe="hidde n " nam e =" index -fi eld" v al ue= "x">      <i nputtype=" su bmit"value =" Submit"> 
    </form>

    <ifra me id= "myFr ame " src="fr ame - box .html"></ ifra me>
</body >
< /ht ml>
But you m ay g e tawa y  with  jus t  detectin g  t hec h an ge in locat i o n  in  theifr a me. Th at w ould involve just changing the p aren t pag e a s  ind ic ated:
<!
't work_on Firefox.
I_am not sure if_solving this_would_solve my_problem,_but at least_this should work_for my library code_to work.

A:

I'm mildly_surprised_to see that it works on any browser. By allowing the parent's form submission_to_occur, you're_tearing_down_the page, which means tearing_down the iframe, and any_requests that_may be underway can be aborted (or if_not_quite started, never_started).
I'd probably switch to ajax rather than doing the_actual form submission.
But if you want_to do the_form_submission,_to do this reliably_you'll have to wait for the_frame's submission to complete before doing_the parent submission. The easy way to_do that is to have the_frame submission respond with a_small page_with JavaScript on it that_tells the parent_it's finish:
<!DOCTYPE_html>
<html>
<body>
<script>
if (parent &&_parent.formCallback) {
    parent.formCallback();
}
</script>
</body>
</html>

Then_the parent page_is something like:
<!DOCTYPE html>
<html>
<head>
  __<script>
  ___ _ function submitFunction()_{
_ __     __ var myFrame = document.getElementById("myFrame");
  _   __   _var myForm = myFrame.contentWindow.document.getElementById("myForm");
 _     _ _ _myForm.submit();
          _ return false; // <−−−−−−−− cancel_submission
   _ __ }
 __ _   function formCallback() { _ _     _   __     _     _ // 
  ___    _  document.getElementById("parentForm").submit();  // <−−−−−−−−_Submit on callback
_      _}_     __     ___    _     _        _  _    ___      // 
  _ </script>
</head>
<body>
_  _<!--  vvvvvvvvvvvvvvv−−−−−−−− Added ID    -->
 _  <form id="parentForm" action="/index-submit" onSubmit="return submitFunction()">
_       <input type="hidden" name="index-field" value="x">
_       <input_type="submit" value="Submit">
    </form>

 _  <iframe id="myFrame"_src="frame-box.html"></iframe>
</body>
</html>

But_you may get away with just detecting_the_change_in_location in the_iframe. That would_involve just changing_the parent_page as indicated:
<!