我有这个按钮:
<img src="static/img/facebook_button.png" id="login-fb" onclick="login();" />
我也有这个脚本:
window.fbAsyncInit = function(){
FB.init({
appId : 'MY_APP_ID',
status : true,
cookie : true,
xfbml : false
});
};
最后,我有这个功能:
function login()
{
facebookPerms = [
'user_photos', 'email', 'offline_access', 'user_relationships', 'read_stream',
'user_about_me', 'user_birthday', 'user_education_history', //'publish_stream',
'user_hometown', 'user_interests', 'user_location', 'user_likes',
'user_religion_politics', 'user_activities', 'user_work_history'
];
//Get the facebook login status
FB.getLoginStatus(function(response) {
if (response.session) {
// logged in and connected user, someone you know
ajaxLogin();
} else {
//Display the facebook login dialog
FB.login(function(response) {
if (response.authResponse) {
// user is logged in and granted some permissions.
// perms is a comma separated list of granted permissions
ajaxLogin();
} else {
// user is not logged in, display the error dialog box
errorNotLogged();
}
}, {
//Ask for permissions of Facebook
scope: facebookPerms.join(',')
});
}
});
}
我遵循Facebook规则:
调用FB.login会导致JS SDK尝试打开弹出窗口 窗口。因此,只应在用户单击后调用此方法 事件,否则大多数浏览器都会阻止弹出窗口。
我的网站仍然在IE9中阻止了它的Facebook弹出窗口。任何想法如何解决这个问题?有没有其他人如何在不阻止脚本的情况下这样做的想法?
答案 0 :(得分:6)
请尝试以下方法:
在您的实现中,FB.login不是在用户交互后直接调用,而是作为FB.getLoginStatus的回调函数的一部分。我想这会导致IE阻止弹出窗口。