我在我的应用程序中使用“登录facebook”。我想点击“使用Facebook登录”按钮后重定向到主页。我不知道如何实现它......
代码是,
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP ID', // App ID
channelUrl : 'http://www.***.com/', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "js/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
<div id="fb-root"></div>
<div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1"></div>
请帮忙,
由于
答案 0 :(得分:1)
使用Facebook活动:
FB.Event.subscribe('auth.login', function(){
window.location = 'index.html';
});
新代码:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP ID', // App ID
channelUrl : 'http://www.***.com/', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.login', function(){
window.location.href = 'index.html';
});
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "js/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
使用您的主页网址更改index.html
。
如果您还要添加logout
:
FB.Event.subscribe('auth.logout', function(){
window.location.href = 'index.html';
});
答案 1 :(得分:0)
将您的登录按钮更改为
<fb:login-button perms="email,publish_stream" autologoutlink="window.location.href='index.html';"></fb:login-button>
将index.html更改为您的主页网址