【发布时间】:2018-01-28 17:32:06
【问题描述】:
我正在从 Facebook 的开发者网站上的 this page 复制代码,并且 fbAsyncInit() 方法永远不会触发。我还阅读了this page,我已经以多种不同的方式调整了代码,但我无法触发该方法。你的意见?
另外,值得一提的是,当我尝试运行此代码和 Chrome(在 Mac 上)并运行 Firebug lite 时,我收到一条错误消息,提示“无法在此页面中加载 Firebug Lite”
这是代码...
<html>
<head>
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : '1234567890', // App ID
channelUrl : '//localhost/test.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
alert("this statement never gets called either");
};
// Load the SDK Asynchronously
(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/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
</script>
</body>
</html>
【问题讨论】:
-
你的文件叫 test.html 吗?
-
是的,有问题吗?
-
有没有js错误?
-
你在什么浏览器中测试它?尝试更改一些不存在的 src,然后检查浏览器中的错误日志。
标签: javascript facebook fbconnect fbjs