点击Facebook登录按钮后重新定向,即使已经登录Facebook [英] Redirect after clicking on the Facebook login button, even if already logged in Facebook
问题描述
我的主页上有标准的Facebook登录按钮,只有用户点击登录按钮,我才想让用户自动登录我的网站。
I have the standard Facebook login button on my homepage and I don't want people to automatically log into my site with their Facebook account, only if the user clicks the login button.
如果用户没有登录Facebook,会出现一个弹出窗口,询问他的凭据,然后他将被重定向到 loggedin.html
。 >
If the user is not logged in Facebook, a popup will appear asking him his credentials and he will be redirected to loggedin.html
after that.
<div id="fb-root"></div>
<fb:login-button perms="email"></fb:login-button>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxx',
status : true,
cookie : true,
xfbml : true
});
FB.Event.subscribe('auth.login', function() {
window.location = "loggedin.html";
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
如果用户已经登录Facebook,当他点击按钮时弹出窗口立即消失我可以这样做但是用户不会被重定向到 loggedin.html
。我该怎么做?
If the user is already logged in Facebook, when he clicks the button the popup appear and disappear right away, I am OK with that. But the user is not redirected to loggedin.html
. How can I do that ?
推荐答案
我也有同样的问题。我通过使用常规链接而不是东西解决它,并添加一个点击处理程序到这个href与Facebook FB.login javascript函数
I had the same problem. I solved it by using a regular link instead of the thingy and adding a click handler to this href with the facebook FB.login javascript function
http://developers.facebook.com/docs/reference/javascript/FB.login/
在不同的答复中,我可以处理相应的Ajax的东西。
Within the different responses I could handle the corresponding Ajax things.
这篇关于点击Facebook登录按钮后重新定向,即使已经登录Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!