我有这个问题。
我在我的 facebook 标签页中有这段代码,正如你所见,当用户来的时候我需要一些权限。问题是,当我单击“关闭”按钮时,FB.login 中的回调没有启动,FB 将其抛出到控制台:
- Chrome:“未捕获的类型错误:无法读取未定义的属性 'e2e'”。
- Firefox:“ea.result 未定义”
行动
代码
...
<script src="//connect.facebook.net/en_US/all.js"></script>
</head>
<body>
<div id="fb-root"></div>
<script>
var api = new Object();
api.login = false;
api.width = 810;
api.height = 970;
function login() {
FB.login(function(response) {
if (response.authResponse) {
// here it works when user click 'Go to app' button
alert('Go to app');
} else {
// here is the problem, because this else doesn't start-
// -when user click 'Close' button
alert('CLOSE');
}
}, {scope: 'email,user_birthday'});
}
function loginStatus(response) {
if (response && response.status === 'connected') {
// already auth
api.login = true;
} else {
login();
}
}
function sizeChangeCallback() {FB.Canvas.setSize({ width: api.width, height: api.height });}
window.fbAsyncInit = function() {
FB.init({
appId : '564323490269057',
status : true,
cookie : true,
xfbml : true
});
FB.Canvas.setSize({ width: api.width, height: api.height });
FB.getLoginStatus(loginStatus);
}
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
</script>
</body>
</html>