如何使用我已有的代码将javascript弹出窗口居中
我需要能够中心弹出窗口出现。我知道这已经被问了很多次了,但我找不到一个有效的。请帮忙如何使用我已有的代码将javascript弹出窗口居中,javascript,popup,window,center,Javascript,Popup,Window,Center,我需要能够中心弹出窗口出现。我知道这已经被问了很多次了,但我找不到一个有效的。请帮忙 jQuery(document).ready(function (jQuery) { jQuery('.open-window').click(function () { var NWin = window.open(jQuery(this).prop('href'), '', 'scrollbars=1,height=400,width=400');
jQuery(document).ready(function (jQuery) {
jQuery('.open-window').click(function () {
var NWin = window.open(jQuery(this).prop('href'), '', 'scrollbars=1,height=400,width=400');
if (window.focus) {
NWin.focus();
}
return false;
});
});
我想这就是你想要的
jQuery(document).ready(function (jQuery) {
var screenWidth = (screen.width-400)/2,
screenHeight = (screen.height-400)/2;
jQuery('.open-window').click(function () {
var NWin = window.open(jQuery(this).prop('href'), '', "'scrollbars=1, height=400, width=400, top="+screenHeight+", left="+screenWidth+"'");
if (window.focus) {
NWin.focus();
}
return false;
});
});
我想这就是你想要的
jQuery(document).ready(function (jQuery) {
var screenWidth = (screen.width-400)/2,
screenHeight = (screen.height-400)/2;
jQuery('.open-window').click(function () {
var NWin = window.open(jQuery(this).prop('href'), '', "'scrollbars=1, height=400, width=400, top="+screenHeight+", left="+screenWidth+"'");
if (window.focus) {
NWin.focus();
}
return false;
});
});
谢谢!工作得很好!非常感谢。工作得很好!