javascript - 如何设置 window.opener() 函数的宽度和高度?

标签 javascript popup facebook-social-plugins window.opener

有一个社交登录 WordPress 插件,当验证来自社交网站(facebook、google 等)的登录时,它会生成一个大的弹出窗口

我想让弹出窗口变得更小,但无法弄清楚。产生弹出窗口的代码是:

if( get_option( 'wsl_settings_use_popup' ) == 1 || ! get_option( 'wsl_settings_use_popup' ) ){
    ?>
        <html><head><script>
        function init() {
            window.opener.wsl_wordpress_social_login({
                'action'   : 'wordpress_social_login',
                'provider' : '<?php echo $provider ?>'
            });

            window.close()
        }

如何设置此弹出窗口的宽度和高度?

提前致谢!

最佳答案

中心窗口更新

provider = $(this).attr("data-provider"); 下方添加此 2 计算:

datop = (($(document).height()-400)/2);
daleft = (($(document).width()-225)/2);

将这 2 个参数添加到属性中:

top="+datop+",left="+daleft+""

像这样:

"location=1,status=0,scrollbars=0,width=225,height=400,top="+datop+",left="+daleft+""

END

编辑

您可以在此处找到该文件:wp-content/plugins/wordpress-social-login/assets/js/connect.js

结束编辑
该文件是“wordpress-social-login\assets\js\connect.js”我不知道该文件将安装在哪里,但可能您可以在包含登录名的每个页面中找到其中的功能(如果可以的话)找到它,您可以卸载,编辑文件并在修改文件的情况下重新安装)。这应该是您正在搜索的功能:

(function($){ 
    $(function(){
        $(".wsl_connect_with_provider").click(function(){//selector.event
            popupurl = $("#wsl_popup_base_url").val();//assign text of the element with id #wls_popup_base..
            provider = $(this).attr("data-provider");//assign the attribute data-provider of the element with class .wls_connect.. 

            window.open(
                popupurl+"provider="+provider,//url
                "hybridauth_social_sing_on", //window name
                "location=1,status=0,scrollbars=0,width=1000,height=600"//attributes of the window
            ); 
        });
    });
})(jQuery);

这应该是弹出窗口的代码

window.open(
    popupurl+"provider="+provider,
    "hybridauth_social_sing_on",
    "location=1,status=0,scrollbars=0,width=1000,height=600"
);

要更改宽度和高度,请编辑这 2 个参数:..width=1000,height=600"

请注意,我添加注释是为了让您了解该函数的作用以及您在做什么

关于javascript - 如何设置 window.opener() 函数的宽度和高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17302026/

相关文章:

laravel - Laravel Socialite在本地主机上测试,SSL证书问题?

css - 帮助在 IE 中隐藏 css 弹出窗口

javascript - 如何在 Semantic-UI 中的弹出数据工具提示中添加换行符

javascript - 进度条计时器暂停时钟

javascript - Reactjs - 这不是升级时的函数错误

flutter - 在 Flutter 中推送新页面时,Navigator 堆栈上的页面会重建

html - 社交插件对齐

facebook - 如何在我的网站上向所有人公开 Facebook 评论?

javascript - 使用 Javascript 通过 Adob​​e Air App 访问 Sharepoint 2007

javascript - 自动取消绑定(bind) JQuery 中的事件处理程序