在我使用的脚本中,以下代码用于将弹出窗口定位在屏幕中间。
我需要以Y
位置与我单击的项目相同的方式更改它。所以如果我点击一个项目,弹出窗口应该显示在与我点击的项目相同的高度。我不知道 jquery 和 2 小时的尝试没有帮助。任何帮助表示赞赏
我标记了需要编辑的行。
switch(a)
{
case 'postdetails':
case 'userdetails':
$('#reputation-popup').addClass('normal-popup');
targetleft = ($(window).width() - $('#reputation-popup').outerWidth()) / 2;
targettop = ($(window).height() - $('#reputation-popup').outerHeight()) / 2;
/////// THE LINE ABOVE THIS IS THE ONE I NEED TO EDIT!!!! //////////
break;
case 'newpopup':
$('#reputation-popup').addClass('new-popup');
targetleft = ($(window).width() - $('#reputation-popup').outerWidth()) / 2;
targettop = ($(window).height() - $('#reputation-popup').outerHeight()) / 2;
break;
default:
$('#reputation-popup').addClass('small-popup');
// Center popup relative to clicked coordinate
targetleft = c.pageX - $('#reputation-popup').outerWidth() / 2;
// Popup can not be too close or behind the right border of the screen
targetleft = Math.min (targetleft, $(document).width() - 20 - $('#reputation-popup').outerWidth());
targetleft = Math.max (targetleft, 20);
targettop = c.pageY + 10;
break;
}