title: Second Javascript form POST fails in Chrome, works in IE and FF
body: <p>I'm opening a new window via a javascript POST in response to a user click in a flash application. The user may close the new window and want to re-open it by clicking the button on the first page again. Since I have to pass some large arguments to the second page, I have to do a POST, a GET won't work. So far I have the second page opening and behaving correctly in Chrome, FF, and IE the first time the button is clicked. However, in Chrome (it works in IE and FF) the second time the button is clicked, the POST is ignored and the new window is not opened.</p>
  
  <p>Here's the function I use to do the POST. I have verified that it is making it all the way past the form.submit() line in Chrome with all the same parameters and no error notifications, but a new window still doesn't open.</p>
  
  <pre><code>function post_to_url(path, paramString) {
      var params = paramString.split("|");
  
      var form = document.createElement("form");
      form.setAttribute("method", "post");
      form.setAttribute("action", path);
      form.setAttribute("target", "_blank");
  
      for (var i=0; i&lt;params.length; i++) {
          var hiddenField = document.createElement("input");
          var param = params[i].split(":");
          hiddenField.setAttribute("type", "hidden");
          hiddenField.setAttribute("name", param[0]);
          hiddenField.setAttribute("value", param[1]);
  
          form.appendChild(hiddenField);
      }
  
      document.body.appendChild(form);
      form.submit();
      document.body.removeChild(form);
  }
  </code></pre>
  
  <p>Any ideas on how this can be modified to get it to work in Chrome also?</p>
  
  <p>Update:
  It appears that the form isn't removed from the DOM in Chrome. I'm not sure if that's the issue or not, but it should be removed regardless.</p>
  
  <p>We've also noticed that while 2nd POSTs in Chrome on Linux and Windows don't go through, they do on Macs. However, even on a Mac the form isn't removed from the DOM.</p>
  
  <p>Another Update:
  Altering the code like this correctly removes the form from the DOM, but it doesn't solve the POST problem.</p>
  
  <pre><code>function post_to_url(path, paramString) {
      var postform = document.getElementById("postform");
      if (postform != null)
          document.body.removeChild(postform);
      var params = paramString.split("|");
  
      var form = document.createElement("form");
      form.setAttribute("method", "post");
      form.setAttribute("action", path);
      form.setAttribute("target", "_blank");
      form.id = "postform";
  
      for (var i=0; i&lt;params.length; i++) {
          var hiddenField = document.createElement("input");
          var param = params[i].split(":");
          hiddenField.setAttribute("type", "hidden");
          hiddenField.setAttribute("name", param[0]);
          hiddenField.setAttribute("value", param[1]);
  
          form.appendChild(hiddenField);
      }
  
      document.body.appendChild(form);
      form.submit();
      var postform = document.getElementById("postform"); 
      document.body.removeChild(postform);
  }
  </code></pre>