Created
February 6, 2017 18:04
-
-
Save Raphhh/6e69410fa413f75659838e0e9896496c to your computer and use it in GitHub Desktop.
Open a new window in Javascript on form submit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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