我已经将我的页面归结为最简单的东西,但它仍然无法在 IE8 中运行。
这是整个 html 页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">
<head></head>
<body>
<div id="fb-root"></div>
<fb:login-button></fb:login-button>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({appId: 'd663755ef4dd07c246e047ea97b44d6a', status: true, cookie: true, xfbml: true});
FB.Event.subscribe('auth.sessionChange', function(response) {
alert(JSON.stringify(response));
});
FB.getLoginStatus(function (response) { alert(JSON.stringify(response)); });
</script>
</body>
</html>
在 firefox、safari 和 chrome(在 Mac 上)中,我得到了我期望的行为:如果我没有登录 Facebook,我会在页面加载时看到一个对话框,其中有一个空 session 。当我单击“登录”按钮并登录时,我会看到第二个带有 session 的对话框。如果我登录到 Facebook,我会收到两个 session 对话:一个来自 getLoginStatus 调用,另一个来自事件。
在 IE8 中,加载页面时没有对话框。未调用 getLoginStatus 回调。当我单击“登录”按钮时,会出现一个对话框,但其中有一个非常奇怪的错误:
Invalid Argument
The Facebook Connect cross-domain receiver URL (http://static.ak.fbcdn.net/connect/xd_proxy.php#?=&cb=f3e91da434653f2&origin=http%3A%2F%2Fmysiteurl.com%2Ff210cba91f2a6d4&relation=opener&transport=flash&frame=f27aa957225164&result=xxRESULTTOKENxx) must have the application's Connect URL (http://mysiteurl.com/) as a prefix. You can configure the Connect URL in the Application Settings Editor.
我已经清理了上面的连接 URL,但它是正确的。
对话框确实有用户名/密码字段。如果我登录,对话框会重定向到我的连接 URL,但没有 fb cookie,所以当然没有任何效果。
我在这里做错了什么?
更新(2010 年 9 月 10 日):
这个问题并不普遍。我的网站网址中有一个端口号, 因为这是我的测试站点:http://mysiteurl.com:12345 .没有端口 号,ie8好像没问题。随着端口号,它继续 像以前一样失败。但是,错误消息现在更简洁了:
Invalid Argument
Given URL is not allowed by the Application configuration
此外,这个问题是 IE 特有的(实际上,我怀疑它是 flash XD 传输特有的,但我不知道如何确认)。它在我尝试过的所有其他平台/浏览器对上运行良好。
我仍然无法使用带有端口号的 url 来完成这项工作。
最佳答案
尝试将 channelUrl 参数传递给您的 FB.init 函数,并按照以下引用链接的建议创建 channel.html 文件:
关于javascript - 如何让新的 Facebook Javascript SDK 在 IE8 中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3003031/