2012-05-11 19 views
2

这是我的第一个应用程序。登录按钮不适用于我的应用程序。它被显示,但是当我点击它时,没有任何反应。登录按钮不能在IE7,8,9上工作

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/"> 
    .... 
    <body> 
    <div id="fb-root"></div> 
    <script> 
     window.fbAsyncInit = function() { 
       FB.init({ 
       appId  : '306025322809511', 
       channel : 'http://koreplayer.fb.levelkro.com/channel.php', 
       status  : true, 
       cookie  : true, 
       xfbml  : true, 
       oauth  : true, 
       }); 
       FB.Event.subscribe('auth.login', function() { 
        if (response.authResponse) { 
          window.location = "/manage.php"; 
        } 
       }); 
     }; 
     (function(d){ 
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} 
     js = d.createElement('script'); js.id = id; js.async = true; 
     js.src = "//connect.facebook.net/fr_FR/all.js"; 
     d.getElementsByTagName('head')[0].appendChild(js); 
     }(document)); 
    </script> 
    .... 
    <div class="fb-login-button">Se connecter en utilisant Facebook</div> 

我尝试过使用通道参数,但没有通道显示样式。

+0

控制台中是否显示任何内容?按F12查看控制台。 – Sampson

+0

控制台只会说“FB没有定义”,如果Y运行调试器,我可以登录。 – levelKro

回答

0

好的,问题是由apps.facebook.com/koreplayer/的iFrame引起的,IE不保存cookie,因为它是在一个框架中。这是IE防止欺诈的安全功能。

0

您需要在“fb-login-button”上触发FB.login()。你可以使用onclick()或者使用jQuery $('.fb-login-button')来实现。click(function(){FB.login();});

此外,下面的问题不会防止登录弹出,但会在登录后停止刷新。所以,如果您已经登录,它会使它看起来像没有任何反应,因为登录盒子就会打开,然后关闭,因为它没有任何关系。

  FB.Event.subscribe('auth.login', function() { 
       if (response.authResponse) { 
         window.location = "/manage.php"; 
       } 
      }); 

需要改变,以

  FB.Event.subscribe('auth.login', function (response) { 
       if (response.authResponse) { 
         window.location = "/manage.php"; 
       } 
      }); 

最后,windows.location最好能有一个完整的URL(以http://或https://)。不必,但应该让它工作得更好。

window.fbAsyncInit = function() { 
     FB.init({ 
     appId  : '306025322809511', 
     channel : 'http://koreplayer.fb.levelkro.com/channel.php', 
     status  : true, 
     cookie  : true, 
     xfbml  : true, 
     oauth  : true, 
     }); 
    }; 
    FB.Event.subscribe('auth.login', function (response) { 
    if (response.authResponse) { 
     window.location = "http://koreplayer.fb.levelkro.com/manage.php"; 
     } 
    }); 

你需要有FB.Event认购fbAsyncInit函数内部:

window.fbAsyncInit = function() { 
     FB.init({ 
     appId  : '306025322809511', 
     channel : 'http://koreplayer.fb.levelkro.com/channel.php', 
     status  : true, 
     cookie  : true, 
     xfbml  : true, 
     oauth  : true, 
     }); 
     FB.Event.subscribe('auth.login', function (response) { 
     if (response.authResponse) { 
      window.location = "http://koreplayer.fb.levelkro.com/manage.php"; 
     } 
     }); 
    }; 

后期编辑:我添加


下面的评论后编辑在帖子第二部分的auth-subscribe参数中的“响应”。

+0

谢谢,但如果我保留FB.Event与您的修复程序,IE做一个循环。 – levelKro

+0

此外,我已经失去了按钮的样式,'FB'没有定义。 – levelKro

+0

我从facebook使用PHP和JS SDK,当用户转到index.php时,PHP返回$ userInfo有效,用户转到manage.php页面,如果在manage.php中,$ userInfo返回false,则用户返回索引。 PHP页面登录。 – levelKro

0

我知道js sdk加载后使用xfbml parse来渲染我的按钮,在下面使用。


<div id="login_button"><div> 
<div id="fb-root"></div> 
<script> 
     window.fbAsyncInit = function() { 
     FB.init({ 
    appId : '135669679827333', 
    status : true, // check login status 
    cookie : true, // enable cookies to allow the server to access the session 
    xfbml : true, // parse XFBML 
    channelUrl : 'https://anotherfeed.com/emo/channel.html', // channel.html file 
    oauth : true // enable OAuth 2.0 
     }); 
function loginbutton(){ 
var loginb=document.getElementById('login_button'); 
login.innerHTML+='<div class="fb-login-button">Se connecter en utilisant Facebook</div>'; 
FB.XFBML.parse(loginb); 
}; 
setTimeout("loginbutton();", 2000); 
     }; 
    // Load the SDK Asynchronously 
(function(d, s, id) { 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) return; 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=135669679827333"; 
    fjs.parentNode.insertBefore(js, fjs); 
}(document, 'script', 'facebook-jssdk')); 
</script> 

注意:这将仅呈现一个登录链接。

+1

我试过这个代码,不工作 – levelKro

+0

什么是不工作关于这个代码? –

+0

该按钮不可见 – levelKro