I want to embed Facebook in an IFrame one way or another

10,388
<iframe src="http://www.facebook.com/" />

I have not tested, but I suspect Facebook might be using some JavaScript like this to break out of frames:

if (top.location != location) {
    top.location.href = document.location.href ;
}

Unfortunately there is nothing you can do about this, except if you were to proxy the entire Facebook site on-the-fly and filter out this JavaScript, which would most likely break other things. Facebook, and many other sites, implement this trick because frames are often used only for malicious purposes (i.e. framing another website with illegitimate ads or scamming).

Edit: I see from your comment that you say this works at the moment. As I explain above, this is really under Facebook's control, unfortunately. If they choose to add the little bit of JavaScript to break out of frames, you can't stop that from running.

Share:
10,388
Rico
Author by

Rico

Software and web developer for a Builder CRM system. But for side business I do small business development through IGOSB.com

Updated on June 04, 2022

Comments

  • Rico
    Rico almost 2 years

    Does anyone know of a solution for this that i may be able to purchase?

    Ok Well facebook no longer allows you to embed into an IFrame and my company wants to have facebook show up on our application which we do by creating a Iframe and embedding. But on Feb 5th facebook took away that ability. So I am looking for someone who has worked around this sollution but no matter what the sollution has to embed within an IFrame...

  • Rico
    Rico about 14 years
    Hmmm ok that seems to work again today but on Feb 5th Facebook took away all ability to use an IFrame... Seems they granted the masses the ability to do it again? shall theytake it away?
  • Rico
    Rico about 14 years
    Well Basically on Feb 5 they had put a black screen over the front of their site if you had it embedded... Thanks for your help i should have tried it again today before asking..