title: How to submit form to new window?
body: <p>I want to insert a form dynamically using JavaScript and then submit it and open target in new window.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>            var form = document.createElement("form");
              form.setAttribute("method", "post");
              form.setAttribute("action", xxx);
              form.setAttribute("onsubmit", "window.open('about:blank','Popup_Window','scrollbars=yes,width=550,height=520');");
              form.setAttribute("target", "Popup_Window");
  
              document.body.appendChild(form);
              form.submit();
  </code></pre>
  
  <p>This code works -- it inserts the form dynamically and submits the form successfully. However, the form is opened in a new tab whereas I want it to open in a new window. Any idea what is up? Any suggestions on how to fix this? I'm open to jQuery as well.</p>
  
  <p>Thanks!</p>
  
  <p>EDIT: I'm not sure why people are marking this as duplicate. Yes, it is on the same topic as the other question but the answers are not related -- the claimed duplicate issue had a new line that was messing up the code, I don't but my code still won't work...</p>