jcsubmit
jcsubmit

Reputation: 146

Facebook FB.Init Refused to display in a frame because it set 'X-Frame-Options' to 'DENY'

Following the Facebook instructions, FB.Init in Chrome produces

Refused to display 'https://www.facebook.com/connect/ping?...' in a frame because it set 'X-Frame-Options' to 'DENY'.

However, there are no frames on the page. IE, strangely enough, seems happy with the call.

Based on a stackoverflow suggestion, I added

<httpProtocol>
    <customHeaders>
      <add name="X-Frame-Options" value="SAMEORIGIN" />
    </customHeaders>
</httpProtocol> 

to system.webServer

to no avail.

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>

Anyone know what is going on?

Upvotes: 2

Views: 4844

Answers (1)

jcsubmit
jcsubmit

Reputation: 146

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.

Upvotes: 1

Related Questions