我想補充FWrnr的回答與實際代碼,因爲這確實非常有幫助。
的解決方案是FB.getLoginStatus功能,他說:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
window.location = //redirect to page with logged user (you have the response token in response)
} else {
//Show the login popup
FB.login(function(response) {
if (response.authResponse) {
window.location = //redirect to location after correct login
}
}, { scope: '<scopes>', state: '<state>' });
}
});
這樣一來,如果用戶「連接」(登錄和應用程序授權),你會不會叫的FB.login方法,所以登錄窗口不會閃爍。在任何其他情況下,它將顯示登錄窗口,這是預期的結果。
我不認爲有一種解決方法 - 它可以被無處不在地看到。但是,我正在考慮彈出式下(可能會加劇瀏覽器)或隱藏的iFrame(除非Facebook使用幀解析器,它可能會這樣做) –