Can't show some websites in iframe tag

后端 未结 4 1223
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 03:35

I am trying to develop a page in which I can show more than 3 website at a time, as below:

相关标签:
4条回答
  • 2020-12-03 03:51

    facebook does not want you to load their main site in frames

    <iframe src="http://m.facebook.com/" width="200" height="300" scrolling="auto" frameborder=0></iframe>
    

    width="200" height="300" can be adjusted accordingly.*

    What this does is load the mobile version of facebook in the frame instead of the main site.

    Reference

    0 讨论(0)
  • 2020-12-03 03:55

    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.

    0 讨论(0)
  • 2020-12-03 04:06

    You will not able to do that, you can only iframe like button... someother not whole site.

    0 讨论(0)
  • 2020-12-03 04:15

    Since some websites have decided to disable embedding them in iframes theres nothing you can do with pure html solutions. You could create a serverside script (in PHP) that pulls the target site via your webserver and then use the html etc.

    The only way I can think of that would enable you to check wether the site has loaded is to search the iframe for a specific element that exists on the target website (for example a div with a specific id or class on the Facebook's front page). The reason would be that different websites can handle being embedded into iframes differently and while some might display some content, some may display nothing etc and the only way to be sure is to check for real elements.

    0 讨论(0)
提交回复
热议问题