我的代码存在问题,即创建Facebook Connect登录弹出窗口。在下面的代码中,如果我在我的文档中包含click事件,那么它会触发创建2个弹出窗口,但是如果我将它留在文档之外,则无法创建任何弹出窗口。有人可以提供建议吗?
<script type="text/javascript">
$(document).ready(function () {
window.FB.init({ appId: 'xxx', status: true, cookie: true, xfbml: true });
});
$('#fbLogin').click(function () {
window.FB.login(function (response) {
if (response.status == 'connected') {
window.location.href = 'redirecturl';
}
}, { perms: 'email' });
});
</script>
<fb:login-button autologoutlink="false" perms="email" id="fbLogin">
</fb:login-button>
答案 0 :(得分:0)
fb:login-button
会启动登录对话框。#fblogin
的绑定将打开第二个对话框您需要选择fb:login-button
或FB.login
中的一个而不是两者。
如果您需要在用户登录后重定向页面,只需删除FB.login
来电并订阅(FB.Event.subscribe
)至auth.statusChange
事件以检查登录状态。
FB.Event.subscribe('auth.statusChange', function(response){
if (response.status == 'connected') {
window.location.href = 'redirecturl';
}
});