我设置了一个 FB.ui 提要来触发与 Facebook 的对话,就像描述的那样 here .
目前一切正常。该对话框发布在 fb 用户个人资料上,但是当 fb 站点打开以供用户发布该对话框时,它会在 js 控制台中抛出数百次错误,直到用户跳过或发布:
错误(130 次): 不安全的 JavaScript 尝试使用 URL ... 访问框架。域、协议(protocol)和端口必须匹配。
带有 i init 的 appId fbjs sdk 已在使用的域中注册:
sub.mydomain.com
传过来的json是这样的:
代码:
window.fbAsyncInit = function() {
FB.init({appId: '209836882377466', status: true, cookie: true,
xfbml: true
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
if (!$('#fb-root script').length>0){
document.getElementById('fb-root').appendChild(e);
}
}());
这里是提要:
var jSON = {
method: 'feed',
name: $('#fbName input').val(),
link: basicLnkStruct + phpSessionID,
picture: homeURL + imgPath,
caption: ' ',
description: $('.fbDescript textarea').val(),
message: ''
};
FB.ui(
jSON
,
function(response) {
if (response && response.post_id) {
//alert('Post was published.');
} else {
//alert('Post was not published.');
}
}
);
为什么会抛出这个错误?
最佳答案
这在另一个线程中得到解决:"Unsafe JavaScript attempt to access frame with URL..." error being continuously generated in Chrome webkit inspector
关于javascript - 在 Facebook 上发帖 ... 工作正常但在控制台中抛出错误 为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5652471/