Facebook FB.Init被拒绝显示在框架中,因为它将"X-Frame-Options"设置为"DENY" [英] Facebook FB.Init Refused to display in a frame because it set 'X-Frame-Options' to 'DENY'
问题描述
按照Facebook的说明,FB.Init在Chrome中生成
Following the Facebook instructions, FB.Init in Chrome produces
拒绝显示" https://www.facebook.com/connect/ping ?...' 在一个 框架,因为它将"X-Frame-Options"设置为"DENY".
Refused to display 'https://www.facebook.com/connect/ping?...' in a frame because it set 'X-Frame-Options' to 'DENY'.
但是,页面上没有框架. IE,奇怪的是,似乎对此通话感到满意.
However, there are no frames on the page. IE, strangely enough, seems happy with the call.
基于stackoverflow的建议,我添加了
Based on a stackoverflow suggestion, I added
<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="SAMEORIGIN" />
</customHeaders>
</httpProtocol>
到system.webServer
无济于事.
所以这里还发生了其他事情.关于SO的问题似乎很多,但没有明确的解决方案.
So something else is happening here. There seems to be a lot questions on SO relating to this problem, but with no clear solution.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>hello world</h1>
<script>
// -----------------------------
var FBinitialised = false;
window.fbAsyncInit = function() {
FB.init({
appId : '<MY_APP_ID>',
cookie : true,
xfbml : true,
version : 'v2.8'
});
console.log( 'after FB.init');
FB.getLoginStatus( function( response){
FBinitialised = true;
console.log( 'FBinitialised');
});
};
// ---------------------------------
// Load the SDK asynchronously
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = '//connect.facebook.net/en_US/sdk.js';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
console.log( 'End of script');
</script>
</body>
</html>
有人知道怎么回事吗?
推荐答案
无聊之后,看来我机器上的Chrome和FF已损坏,也许是因为注入了卡巴斯基脚本.重新安装W10已解决了该问题.抱歉.
After much boredom, it appears that Chrome and FF on my machine have been corrupted, perhaps by Kaspersky script injection. Re-installing W10 has solved the problem. Apologies.
这篇关于Facebook FB.Init被拒绝显示在框架中,因为它将"X-Frame-Options"设置为"DENY"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!