2012-12-19 26 views
0

登录对话框来了,而不点击登录按钮。我的网站上的facebook登录对话框

如何停止加载对话框,不点击“登录”

检查我的网站http://wwwtechnologies.com/ 我在FB应用给出此设置 应用程序域:wwwtechnologies.com 网站与Facebook登录:HTTP:// wwwtechnologies .COM/

另一个问题:

如何让这个人

<!-- FB LOGIN --> 

<div id="fb-root"></div> 
<script> 
// Additional JS functions here 
window.fbAsyncInit = function() { 
FB.init({ 
appId  : 'xxxxxxxx', // App ID 
//channelUrl : '//wwwtechnologies.com/channel.html', // Channel File 
status  : true, // check login status 
cookie  : true, // enable cookies to allow the server to access the session 
xfbml  : true // parse XFBML 
}); 

FB.getLoginStatus(function(response) { 
if (response.status === 'connected') { 
// connected 
} else if (response.status === 'not_authorized') { 
// not_authorized 
login(); 
} else { 
// not_logged_in 
login(); 
} 
}); 
// Additional init code here 

}; 

// 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 = "//connect.facebook.net/en_US/all.js"; 
ref.parentNode.insertBefore(js, ref); 
}(document)); 

function login() { 
FB.login(function(response) { 
if (response.authResponse) { 
testAPI(); 

window.location.href = "index.php"; 
// connected 
} else { 
// cancelled 
} 
}); 
} 

function testAPI() { 
console.log('Welcome! Fetching your information.... '); 
FB.api('/me', function(response) { 
//var myname = '+response.name+'; 
//alert(myname); 
console.log('Good to see you, ' + response.name + '.'); 
}); 
} 
</script> 

<!-- FB LOGIN --> 
012 Facebook的名字

回答

0

只要加载JavaScript SDK,就会调用window.fbAsyncInit函数。在该功能中,您已经放置了您的FB.getLoginStatus逻辑。你需要做的是从window.fbAsyncInit中取出FB.getLoginStatus,并在用户点击登录按钮时触发它。

function doLogin(){ 
    FB.getLoginStatus(function(response) { 
    if (response.status === 'connected') { 
     // connected 
    } else if (response.status === 'not_authorized') { 
     // not_authorized 
     login(); 
    } else { 
     // not_logged_in 
     login(); 
    } 
    }); 
} 


<button onclick="doLogin();">Login</button>