我一直在使用这样的JQuery对话框:$(thisDialog).dialog();,直到我了解到它不喜欢IE9模式,而doctype严格不是一个选项,因为遗留代码,我如何从这个例子的弹出式中心?
http://jsfiddle.net/46jYC/3/
发布于 2014-07-22 16:57:15
考虑模态对话框的jQuery解决方案是位置绝对/相对/固定的:
var windowHeight = $(window).height();
var windowWidth = $(window).width();
var boxHeight = $('.modal-dialog').height();
var boxWidth = $('.modal-dialog').width();
$('.modal-dialog').css({'left' : ((windowWidth - boxWidth)/2), 'top' : ((windowHeight - boxHeight)/2)}); //change selector to whatever your selector is :)考虑到模态对话框不是位置绝对/相对/固定的jQuery解决方案:
css:
margin-left: auto;
margin-right: auto;jquery:
var windowHeight = $(window).height();
var boxHeight = $('.modal-dialog').height();
$('.modal-dialog').css({'margin-top' : ((windowHeight - boxHeight )/2)}); //change selector to whatever your selector is :)发布于 2014-07-22 16:57:08
你应该写这样的东西:
function abrirPopup(url,w,h) {
var newW = w + 100;
var newH = h + 100;
var left = (screen.width - newW) / 2;
var top = (screen.height - newH) / 2;
var newwindow = window.open(url, 'name', 'width=' + newW +
',height=' + newH + ',left=' + left + ',top=' + top);
newwindow.resizeTo(newW, newH);
//posiciona o popup no centro da tela
//(position the popup in the center of the canvas)
newwindow.moveTo(left, top);
newwindow.focus();
return false;
}HTML:
<a href="#" onclick="return abrirPopup('http://www.google.com.br', 500, 400)">Google</a>https://stackoverflow.com/questions/24893290
复制相似问题