0

我为我的网站创建了一个Facebook登录应用程序。但弹出式窗口拦截器阻止它。我在谷歌搜索它说要添加一个onclick选项,我有一个。但仍然无法正常工作。我已张贴下面如何防止在facebook连接的弹出窗口阻止网站?

js代码我的代码:

$(document).ready(function() { 

window.fbAsyncInitialize = function() { 
    FB.init({ 
     appId  : '', // App ID 
     channelUrl : '..../channel.html', // Channel File 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
    }); 
    FB.getLoginStatus(function(response) { 
    if (response.status === 'connected') { 
     // connected 
     apiCall(); 
    } else if (response.status === 'not_authorized') { 
     // not_authorized 
     login(); 
    } else { 
     // not_logged_in 
     login(); 
    } 
    }); 

    }; 

    function login() { 
    FB.login(function(response) { 
     if (response.authResponse) { 
      // connected 
      apiCall(); 
     } else { 
      // cancelled 
     } 
    }, { scope: 'email' }); 
    } 

    function apiCall() { 

    console.log('Welcome! Fetching your information.... '); 
    FB.api('/me', function(response) { 

     var first_name = response.first_name; 
     var last_name = response.last_name; 
     var fb_id = response.id; 
     var email = response.email; 


    }); 
    } 

    // Load the SDK Asynchronously 
    (function(d){ 
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement('script'); js.id = id; js.async = true; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    ref.parentNode.insertBefore(js, ref); 
    }(document)); 
}); 

HTML:

我应该怎么更改或添加,以防止弹出式窗口拦截问题?

感谢

回答

0

您可以将用户的登录页面重定向,而不是弹出的授权对话框。

您还可以通过用户操作触发登录 - 如果用户单击触发弹出窗口的链接,它将不太可能被阻止(而不是以编程方式触发登录)。

相关问题