javascript - How to submit form to new window? -
i want insert form dynamically using javascript , submit , open target in new window.
here 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 -- inserts form dynamically , submits form successfully. however, form opened in new tab whereas want open in new window. idea up? suggestions on how fix this? i'm open jquery well.
thanks!
edit: i'm not sure why people marking duplicate. yes, on same topic other question answers not related -- claimed duplicate issue had new line messing code, don't code still won't work...
i've marked duplicate because thought problem how send form popup window. here how without using onsubmit
event:
var form = document.createelement("form"); form.setattribute("method", "post"); form.setattribute("action", xxx); function submittopopup(f) { var w = window.open('', 'form-target', 'width=600, height=400, any-other-option, ...'); f.target = 'form-target'; f.submit(); }; document.body.appendchild(form); submittopopup(form);
so instead of using onsubmit
event create popup there, create first, before sending form, , send form it.
Comments
Post a Comment