我正在尝试有一个窗口弹出时,有人点击一个相册从选择的选项。我可以弹出一个新的标签,但还不能让一个新的窗口弹出并居中。下面是我使用过的代码:
function popup(pageURL, title, popupWidth, popupHeight)
{
var left = (screen.width / 2) - (popupWidth / 2);
var top = (screen.height / 2) - (popupHeight / 2);
var targetPop = window.open(pageURL, title, 'toolbar=no, location=no,directories=no,status=no, menubar=no, scrollbars=YES, resizable=YES, copyhistory=no,width=' + popupWidth + ', height=' + popupHeight + ', top=' + top + ', left=' + left);
}然后,当您从选择框中选择一个特定的专辑时,我调用popup()函数,如下所示:
popup('http://www.google.com', 'googlePopup',700,600)我使用谷歌只是为了测试目的。
我可以得到一个窗口打开与谷歌,但它打开在一个新的标签,而不是一个新的窗口居中
发布于 2013-11-10 18:33:38
弹出窗口是在新窗口中打开还是在新选项卡中打开,取决于用户首选项。您无法更改此行为。
如果你想要一个可以打开中心屏幕的弹出式窗口,我建议你使用一个纯HTML解决方案,并在你的页面上放置一个层。您可以使用像jQuery UI这样的库(或任何其他可用的库)
发布于 2013-11-10 18:52:25
“你能试试这个吗?”screenX和screenY补充道
var targetPop = window.open(pageURL, title, 'toolbar=no, location=no,directories=no,status=no, menubar=no, scrollbars=YES, resizable=YES, copyhistory=no,width=' + popupWidth + ', height=' + popupHeight + ', top=' + top + ', left=' + left+",screenX=" + left + ",screenY="
+ top);https://stackoverflow.com/questions/19888637
复制相似问题