Skip to content

Instantly share code, notes, and snippets.

@Raphhh
Created February 6, 2017 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raphhh/6e69410fa413f75659838e0e9896496c to your computer and use it in GitHub Desktop.
Save Raphhh/6e69410fa413f75659838e0e9896496c to your computer and use it in GitHub Desktop.
Open a new window in Javascript on form submit
function delegateFormInNewWindow(form, width, height) {
var left = (screen.width/2)-(width/2);
var top = (screen.height/2)-(height/2);
var dialog = window.open(form.action, '_form', 'resizable,width='+width+',height='+height+',top='+top+',left='+left );
form.target='_form';
return dialog;
}
$(function() {
$('form').on('submit', function(evt) {
delegateFormInNewWindow(this, 800, 400);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment