如何在弹出窗口中居中水平滚动条

时间:2017-09-18 03:09:54

标签: javascript html popup linkedin social

我在“推广”页面中添加了社交分享按钮。 https://www.biznessapps.com/cms/promote

如果您遇到登录页面,可以使用以下凭据登录: https://www.biznessapps.com/cms/login_v2

  

用户名:paulz+099@biznessapps.com

     

密码:paulz + 099

一切都还可以,但LinkedIn显示水平滚动条,我想横向居中。

如果我没有登录到LinkedIn帐户,弹出窗口将重定向到某些URL,如: https://www.linkedin.com/start/join?session_redirect=https%3A%2F%2Fwww.linkedin.com%2Fsharing%2Fshare-offsite%3Fmini%3Dtrue%26url%3Dhttp%253A%252F%252Fwww.biznessapps.com%252Fmobile%252F%253Fappcode%253Dpaulz06351%26title%3DBuild%2BYour%2BApp%26summary%3DCheck%2Bout%2Bthis%2Bapp%2BI%2527m%2Bbuilding%2Bthrough%2BBizness%2BApps%2521%2B%255Bweb%2Bapp%255D%26source%3Dmy%2527%2Ba%2522%2B%252F%257E%2521%2540%2521%2540%2521%2540aasaasasasasa&trk=login_reg_redirect

实际: https://www.screencast.com/t/cbFl1Jl9

预期: https://www.screencast.com/t/p88bQ67zb

这是我在屏幕上打开一个新窗口的Javascript函数:

var openSocialWindow = function(url, width, height) {
      var leftPosition, topPosition;
      //Allow for borders.
      leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
      //Allow for title and status bars.
      topPosition = (window.screen.height / 2) - ((height / 2) + 50);
      //Open the window.
      
      var sWindow = window.open(url, '', "status=no,height=" + height + ",width=" + width + ",resizable=yes,left="
      + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY="
      + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no,centerscreen=yes");
};

openSocialWindow("https://www.linkedin.com/shareArticle?mini=true", 600, 600);

由于Stackoverflow站点的限制,上面的代码段没有显示新的窗口。它仅供参考。

谢谢, 保罗。

1 个答案:

答案 0 :(得分:0)

尝试在创建窗口后运行它:

sWindow.scrollBy(window.screen.width / 2 ,0);

如果没有运气,请尝试:

sWindow.scrollTo(window.screen.width / 2 ,0);