Multiple submits in one action do not work in IE8 on Win7 64-bit
I have 2 frames on a page where frame1 calls into a Javascript method on frame2. In frame2 we do a submit which doesn't happen. When we return to frame1, it does it's own submit and that works fine. Both submits are POSTing data to the server.
FRAME1.HTM
function doSubmit(selectedTab)
{
if (checkFieldsChanged() == true)
{
...
if(selectedTab >= 0)
document.forms[0].action="WebDesk?op=dm&id=11097DETH000000&FormNo=" + selectedTab;
document.forms[0].submit();
}
}
function checkFieldsChanged()
{
...
if (confirm("Do you want to save the changes you have made?"))
{
// try to submit the form.
try
{
return parent.frames[1].doSubmit();
}
catch (e)
{
...
}
}
return true;
}
...
<FORM METHOD="POST" ACTION="WebDesk?op=dm&id=11097DETH000000&FormNo=" TARGET="WorkitemContents11097DETH000000">
FRAME2.HTM
function doSubmit()
{
...
**// Nothing happens here on this submit
document.forms[0].submit();**
return true;
}
...
<form METHOD='POST' ACTION='WebDesk?' onsubmit="return ReqdFieldChk();">
<input TYPE='hidden' NAME='op' VALUE='f'/>
<input TYPE='hidden' NAME='id' VALUE='11097DETH000000'/>
<input TYPE='hidden' id='FormNo' NAME='FormNo' VALUE='3'/>
<input TYPE='hidden' id='send' NAME='send' VALUE='false'/>
So FRAME1's doSubmit is called by the onclick handler which calls checkFieldsChanged which does the doSubmit on FRAME2. When we call submit in FRAME2, nothing happens. Then when we return out to FRAME1, it's submit happens and that always works fine.
I suspect that chaining these 2 submits together for one user-action is not allowed. Or, IE8 doesn't like this and doesn't allow it.
I've done lots of debugging:
- This works properly in IE6 on XP.
- I know the submit routine is actually called because I put calls to console.log around it and it's always called
- If I set a breakpoint on the submit line inside the IE debugger and hit F10 to step over the line, the submit works. However, if I hit F5 to just continue the rest of the script, it doesn't work. So, this might seem to indicate a timing issue
- I put in an async call to do the submit at a later time but that didn't help
- FRAME2.HTM is generated inline by some code and it had some HTML validation issues. I have fixed those and the problem still remains
- In Firefox 3.6.8, sometimes it works, sometimes it doesn't. I haven't figured out when it works and when it doesn't.
- I've run a program, HTTP Analyzer, which looks at the output from IE and it shows nothing coming out of the bad submit. It shows the correct output for the 2nd submit that does work. When I do the F10 to step over the submit (and it works properly), the response that comes back from the server is truncated. The response from the 2nd submit (that also works) is normal. In reality you wouldn't notice anything wrong here because the 2nd submit replaces FRAME2 so it's not a problem. But it might be a symptom that the first submit is truncated.
- I've tried compatibility view but that hasn't helped
- I've done tons of Google searches and come up with nothing concrete.
开发者_运维百科I can provide the raw HTML but I don't want to add more to this already large question.
It really boils down to: can we chain these multiple submits together from one user-action? It's worked fine for years on IE6 but now it breaks on IE8.
in frame2.htm doSubmit() try this:
function doSubmit()
{
var frameId = document.getElementById('iframe_id');
var frameWindow= frameId .contentWindow || frameId .contentDocument;
frameWindow.forms[0].submit();
}
精彩评论