How to embed a facebook page in an iframe?
For my application I need to embed Facebook page in an iframe, here is the html code:
<html>
<head></head>
<body>
<iframe src="http://www.facebook.com" style="width:100%;height:100%">
</body>
<开发者_如何学Go;/html>
But it does not work, any idea why and how to circumvent ?
I belive facebook as an anti framing script. It detects if it is within a iframe and shows a logo which when you click on takes you out of the iframe. Maybe they have an sdk which allows authenticate first and then it will allow the iframe. I Don't know.
More Info: http://developers.facebook.com/search?q=Fb:iframe
I know this is a bit old - but it came up in my search when I was looking for a similar answer. You can get the code to embed an iframe containing public posts, comments etc (a bit like YouTube embed) from this page: https://developers.facebook.com/docs/plugins/embedded-posts/ using the social plugins. I don't think Facebook will ever allow you to iframe the whole site though.
You can proxy the request through your server. Basically request the url from your server https://example.com?url=facebook.com and then write some logic to have your server request all the urls needed to load the page. I wouldn't recommend this for anything commercial however as it wouldn't make facebook happy.
A better solution would be to use the facebook iframe. You can programatically convert any fb page url into the url fb allows you to insert into an iframe. Check their docs for more info. For fb pages it works perfectly.
You have to check for HTTP response header X-Frame-Option of those sites. if its value is "DENY or SAMEORIGIN", then you can not load those website in the iframes.
DENY = No one can load the website in iframe. Even the same domain page wont be able to load. SAMEORIGIN = only a page which is in same domain can load this website in iframe.
First of all, Remember to start href value with "https://" instead of "http://". Note: You should not put any curly brackets after "href".
Considering it, now please try this code bellow.
<iframe src="https://www.facebook.com/plugins/page.php?href={your_facebook_page}&tabs=timeline&width=340&height=300&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true&appId" width="340" height="300" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"></iframe>
Now it is working. Example code below:
faceframe.html
<iframe src="file:///C:/Users/Zishan Ahamed/Desktop/ff1.html" width="100%" height="350px" border="0" scrolling="auto" /></iframe>
ff1.html
<meta http-equiv="refresh" content="0; url=https://facebook.com/" />
Open faceframe.html...
Now this done. try it it's working...
精彩评论