Roh*_*wal 30 javascript jquery facebook fbml fbconnect
我正在使用fb登录功能,但问题是,每当我在页面媒体加载完成之前单击fb登录按钮时,它会阻止fb登录的弹出窗口,但如果我在第二次传递给加载事件后点击fblogin它作品
这是我正在使用的功能:
function fb_login() {
var email='';
console.log(loginClassbackQueue);
// console.log('user wants to login with fb');
FB.getLoginStatus(function(response) {
if(response.status!='connected'){
FB.login(function(response) {
// console.log(response);
if (response.authResponse) {
// console.log('user logged in successfully');
// console.log(response);
email = update_f_data_login(response);
$('#fb_login_popup, #popup_overlay').hide();
// loginme(email);
}
else {
loginClassbackQueue = [];
// console.log('user failed to login');
}
// console.log('fb login completed successfully');
}, {scope:"email,user_birthday,user_likes,user_location,friends_likes,publish_actions"}
);
}
else{
// console.log('logged in and connected');
email = update_f_data_login(response);
$('#fb_login_popup, #popup_overlay').hide();
}
});
}
Run Code Online (Sandbox Code Playgroud)
当我在这个网站上做同样的动作http://fab.com/它打开弹出窗口总是永远不会阻止弹出窗口.
Fis*_*sch 55
你不能FB.login从回调中打电话FB.getLoginStatus.
浏览器倾向于阻止弹出窗口弹出窗口不是由用户的单击操作立即产生的.
因为FB.getLoginStatus做一个ajax呼叫,并调用FB.login它的响应,将作为这个调用的结果打开弹出窗口阻止.
解决问题的方法是调用FB.getLoginStatus页面加载并使用fb_login()方法中的响应.
And*_*ewF 41
只要您确信登录状态已在内部加载,FB.login从回调调用就可以了.为此,请使用以下方法之一:FB.getLoginStatus
FB.init({..., status: true, ... }).FB.getLoginStatus(...)FB.login(...)FB.ui(...)从技术上讲,所有这些选项都使用FB.ui.异步过程必须完成,这可能需要几秒钟.只要您已经使用上述方法之一与FB进行跨域调用,并且异步进程已完成,获取登录状态将不会进行异步调用,并且不会阻止弹出窗口.
您还应该确保不要true为第二个参数指定,如FB.getLoginStatus(..., true);.
Rus*_*ces 12
确保将状态设置为true,这将修复弹出窗口阻止程序问题.
window.fbAsyncInit = function() {
FB.init({
appId : '{your-app-id}',
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.5', // use graph api version 2.5
status : true // set this status to true, this will fixed popup blocker issue
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45787 次 |
| 最近记录: |