akalenuk
akalenuk

Reputation: 3845

How to check if a certain page is embeded to Facebook?

I have a site, which works both as a standalone and as embedded into Facebook. Generally it works ok, but I want a content on some of its pages vary depending on is it embedded or not. I mean is it browsed via Facebook right now. How can I do this?

Upvotes: 0

Views: 51

Answers (2)

C3roe
C3roe

Reputation: 96424

Using a server-side language, you could see if there is a signed_request POST parameter passed to your app on the initial load into the iframe (if so, you’re most likely inside facebook.com with your page), and then save that info into your session, so that you still know where you are once the user starts navigation inside your app in the iframe.

Upvotes: 2

Cal McLean
Cal McLean

Reputation: 1438

If by 'embedded' you mean functioning as a Canvas App in Facebook, then how about a simple:

if (window.location.indexOf("facebook.com") !== -1){
    //Not embedded
} else {
    //Embedded in Facebook as a canvas app.
}

Would that do the trick for you?

Upvotes: 0

Related Questions