为什么FB.getLoginStatus在IE7中不起作用?

nov*_*ino 7 facebook internet-explorer-7

我正在使用FB.getLoginStatusFacebook的应用程序.这适用于所有浏览器,包括IE8.但它不适用于IE7.我的代码是:

       FB.getLoginStatus(function(response) {              
           if (response.session) {
              alert("logout");
            }
            else{
                FB.Event.subscribe('auth.login', function(response) {
                    login();
                });
              alert("login");
            }
        });
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么?

Duc*_*tro 10

根据http://developers.facebook.com/docs/reference/javascript/fb.init/上的文档,正确的解决方案是在您的Web服务器上创建一个文件(例如channel.html),其中包含:

 <script src="http://connect.facebook.net/en_US/all.js"></script>
Run Code Online (Sandbox Code Playgroud)

然后在init选项中指定channel.html的绝对URL:

 <div id="fb-root"></div>
 <script src="http://connect.facebook.net/en_US/all.js"></script>
 <script>
   FB.init({
     appId  : 'YOUR APP ID',
     channelUrl  : 'http://example.com/channel.html'  // custom channel
   });
 </script>
Run Code Online (Sandbox Code Playgroud)

为了方便部署,我使用以下方法来计算我的channelUrl.

 var curLoc = window.location;
 curLoc.protocol + "//" + curLoc.hostname + ":" + curLoc.port + "/channel.html"
Run Code Online (Sandbox Code Playgroud)