为什么FB.getLoginStatus在IE7中不起作用? [英] Why FB.getLoginStatus doesn't work in IE7?
问题描述
我正在将FB.getLoginStatus
用于Facebook中的应用程序.这在包括IE8在内的所有浏览器中都可以正常工作.但是它不适用于IE7.我的代码是:
I am using FB.getLoginStatus
for an application in Facebook. This works fine in all the browsers, including IE8. But it doesn't work for IE7. My code is:
FB.getLoginStatus(function(response) {
if (response.session) {
alert("logout");
}
else{
FB.Event.subscribe('auth.login', function(response) {
login();
});
alert("login");
}
});
有人知道为什么吗?
推荐答案
根据 http://developers.facebook.com/docs/reference/javascript/fb.init/,正确的解决方案是在您的Web服务器上创建一个文件(例如channel.html
),其中仅包含:
According to the documentation at http://developers.facebook.com/docs/reference/javascript/fb.init/, the proper solution is to create a file on your web server (for instance channel.html
) containing just:
<script src="http://connect.facebook.net/en_US/all.js"></script>
然后在init选项中指定您的channel.html的绝对URL:
And then specifying the absolute URL to your channel.html in your init options:
<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>
为了便于部署,我使用以下代码来计算channelUrl.
For convenience in deployment, I use the following to calculate my channelUrl.
var curLoc = window.location;
curLoc.protocol + "//" + curLoc.hostname + ":" + curLoc.port + "/channel.html"
这篇关于为什么FB.getLoginStatus在IE7中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!