I have a script that submits a form to a popup window but instead of displaying the form's action (process.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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With