如何使用我已有的代码将 javascript 弹出窗口 window 居中
How to center a javascript popup window with the code I already have
我需要能够使出现的弹出窗口 window 居中。我知道这已被问过很多次,但我找不到有效的方法。请帮忙!
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;
});
});
我需要能够使出现的弹出窗口 window 居中。我知道这已被问过很多次,但我找不到有效的方法。请帮忙!
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;
});
});