开发者

Submit form to popup window?

I have a script that submits a form to a popup window but instead of displaying the form's action (pr开发者_开发问答ocess.php), it displays nothing (blank window). Heres my script:

function redirectOutput() {
var myForm = document.getElementById('formID');
var w = window.open('about:blank','Popup_Window','toolbar=0,scrollbars=0,location=0,statusb
ar=0,menubar=0,resizable=0,width=400,height=300,left = 312,top = 234');
myForm.target = 'Popup_Window';
return true;
}


It works, but you have a newline suddenly in your window.open.

This works just fine for me: http://jsfiddle.net/pimvdb/N3YSG/.

var myForm = document.getElementById('formID');
myForm.onsubmit = function() {
    var w = window.open('about:blank','Popup_Window','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 312,top = 234');
    this.target = 'Popup_Window';
};


An easy way to submit form in popup window:

HTML:

<form action="..." method="post" onsubmit="target_popup(this)">
    <!-- form fields etc here -->
</form>

Javascript:

function target_popup(form) {
    window.open('', 'formpopup', 'width=400,height=400,resizeable,scrollbars');
    form.target = 'formpopup';
}

Source: http://www.electrictoolbox.com/post-form-popup-window-javascript-jquery/


Why dont you just do it inside of the <form>?

<form target="_blank">...</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜