0

all browsers are fine with my code except the IE. Do you know what I can do better to get it also run with the IE?

<script>

  function submitForm(formId) {
    var w = window.open('', 'myPopup', "width=600, height=600");
    $(formId).attr('target', 'myPopup');
    $(formId).submit();
    w.focus();
    return false;
  }
</script>


<form target="myPopup" onsubmit="return submitForm(this);" method="post" action="" name="myForm" id="myForm">
  <input type="submit" />
</form>
ownking
  • 1,956
  • 1
  • 24
  • 34
  • Could you explain what happens when you hit the submit button in IE? I get another window with a submit button. – Rob Mar 06 '12 at 14:53
  • With the other browsers, the windoes pops up and within 1 sec the content appears. With IE, the win pops up and stays blank for more than 10sec. When I try to close the pop up, it appears again for 3-5 times or the borwser crashes. – ownking Mar 06 '12 at 15:03
  • 1
    Okay, so I found [this link](http://stackoverflow.com/a/8437348/1118431) that talks about issues with the submit button and forms in IE9. It may not be exactly what you're looking for, but it's a start. – Rob Mar 06 '12 at 15:08

1 Answers1

0

I found it out. I just wanted to comment that the "onsubmit" handler produces an endless loop. Then I found this bug report:

If you want to submit a form, you need to access the form’s submit method, e.g. $('form')[0].submit(). When you call $('form').submit() you are generating a submit event, so your event handler gets called in an endless loop.

So the solution is to change

$(formId).submit();

to

$(formId)[0].submit();
ownking
  • 1,956
  • 1
  • 24
  • 34