I want to insert a form dynamically using JavaScript and then submit it and open target in new window.
Here is my 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();
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.
Thanks!
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...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…