fb登录弹出窗口 [英] fb login popup block
问题描述
这是我使用的功能:
function fb_login(){
var email ='';
console.log(loginClassbackQueue);
// console.log('user want 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登录并连接');
email = u pdate_f_data_login(响应);
$('#fb_login_popup,#popup_overlay')。hide();
}
});
}
在本网站上执行的相同操作 http://fab.com/ 它打开弹出窗口永远不会阻止弹出窗口。
您不能从 FB.getLoginStatus
的回调函中调用 FB.login
。
浏览器倾向于阻止弹出窗口的弹出窗口不是用户点击操作的直接结果。
因为 FB.getLoginStatus
执行 ajax
调用,并调用 FB.login
对此响应,由于该呼叫而打开的弹出窗口是阻止。
解决您的问题将在页面加载时调用 FB.getLoginStatus
,并使用 fb_login()
方法中的响应。
I am making using fb login feature but problem comming to me is that whenever I click on the fb login button before page media loading is completed, it blocks the popup for fb login but if I click on fblogin after a second passed to loading event it works
Here is the function I am using:
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();
}
});
}
The same action when I do on this site http://fab.com/ it open popups always never block a popup.
You cannot call FB.login
from the callback of FB.getLoginStatus
.
Browsers tend to block popup windows of the popup is not spawned as an immediate result of a user's click action.
Because FB.getLoginStatus
does an ajax
call and you call FB.login
on it's response, the popup that would open as a result of this call is blocked.
A solution to your problem would be to call FB.getLoginStatus
on page load and use the response inside your fb_login()
method.
这篇关于fb登录弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!