How to embed a facebook page in an iframe?

2019-02-19 09:30发布

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>
</html>

But it does not work, any idea why and how to circumvent ?

4条回答
beautiful°
2楼-- · 2019-02-19 10:06

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...

查看更多
别忘想泡老子
3楼-- · 2019-02-19 10:23

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.

查看更多
相关推荐>>
4楼-- · 2019-02-19 10:26

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.

查看更多
萌系小妹纸
5楼-- · 2019-02-19 10:31

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

查看更多
登录 后发表回答