Skip to content

Instantly share code, notes, and snippets.

@tsyber1an
Created January 19, 2012 14:37
Show Gist options
  • Save tsyber1an/1640355 to your computer and use it in GitHub Desktop.
Save tsyber1an/1640355 to your computer and use it in GitHub Desktop.
popup centered nested window in html
function popupCenter(url, width, height, name) {
var left = (screen.width/2)-(width/2);
var top = (screen.height/2)-(height/2);
return window.open(url, name, "menubar=no,toolbar=no,status=no,width="+width+",height="+height+",toolbar=no,resizable=yes,scrollbars=yes,left="+left+",top="+top);
};
/* Usage by example */
jQuery('.auth_form').submit(function(e){
var $form = jQuery(this);
var social = $form.find('input[name=social]:checked');
if( social.length > 0 )
{
var _href = '/users/auth/' + social.val();
popupCenter(_href, 640, 480, "authPopup");
e.stopPropagation();
return false;
}
return true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment