微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Facebook 社交登录页面正在加载偏离中心

如何解决Facebook 社交登录页面正在加载偏离中心

我正在启动一个用于 Facebook 社交登录的弹出窗口。

但是当连接到 Facebook 时,“https://facebook.com/login/reauth.PHP页面会偏离中心加载。因此,对用户隐藏了一半的表单和“继续”按钮。

Facebook 加载时的样子(偏离中心):https://imgur.com/a/dxhjSfA

但我需要它像这样加载(在弹出窗口中):https://imgur.com/a/n8Swqs2

如何让它居中?

这是我用来启动弹出窗口的内容。它在打开窗口的中心启动,但我无法使加载的 Facebook 页面在弹出窗口中居中:

let windowObjectReference = null;
let prevIoUsUrl = null;

const openSignInWindow = (url,name) => {

    // remove any existing event listeners
    window.removeEventListener('message',receiveMessage);

    // window features (open in center of opening window - works well for multi monitor setups)
    const w = '600';
    const h = '700';
    const y = window.outerHeight / 2 + window.screenY - ( h / 2);
    const x = window.outerWidth / 2 + window.screenX - ( w / 2);
    const strWindowFeatures =
        `toolbar=no,menubar=no,width=${w},height=${h},top=${y},left=${x}`;

    if (windowObjectReference === null || windowObjectReference.closed) {
        /* if the pointer to the window object in memory does not exist
         or if such pointer exists but the window was closed */
        windowObjectReference = window.open(url,name,strWindowFeatures);
    } else if (prevIoUsUrl !== url) {
        /* if the resource to load is different,then we load it in the already opened secondary window and then
         we bring such window back on top/in front of its parent window. */
        windowObjectReference = window.open(url,strWindowFeatures);
        windowObjectReference.focus();
    } else {
        /* else the window reference must exist and the window
         is not closed; therefore,we can bring it back on top of any other
         window with the focus() method. There would be no need to re-create
         the window or to reload the referenced resource. */
        windowObjectReference.focus();
    }

    // add the listener for receiving a message from the popup
    window.addEventListener('message',receiveMessage,false);

    // assign the prevIoUs URL
    prevIoUsUrl = url;

};

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。