3

I have some html that loads a page into an iframe. This works fine with this page, for example:

https://seandavi.github.io/

However, a page like this:

https://twitter.com/seandavis12/

results in an empty iframe. I suspect this has to do with the page from twitter being rendered in parts using javascript, but I am not sure how to force the page to display in an iframe. Any suggestions?

Environments I have tested: chrome & safari on mac OS

Minimal example:

<html>
  <body>
    <iframe src="https://seandavi.github.io"></iframe>
    <iframe src="https://twitter.com/seandavis12/"></iframe>
  </body>
</html>

1
  • 1
    show us the code you are using so we can attempt to reproduce the problem Dec 3, 2017 at 17:52
5

You won't be able to embed Twitter in an iframe - they have HTTP headers set which your browser sees and prevents the iframe content from being rendered.

If you open your browser console you will be able to see it being blocked:

enter image description here

Twitter will allow you to embed a specific tweet on a page, however, but you must follow their guide on how to do this: https://dev.twitter.com/web/embedded-tweets

1
  • 1
    Thanks. The general takeway for me was to look in the console. Other websites have other causes (eg., "Refused to display 'support.bioconductor.org' in a frame because it set 'X-Frame-Options' to 'sameorigin'.")
    – seandavi
    Dec 3, 2017 at 18:05
0

Short answer is you can't use iframe/frame/embed/object or any other regular embedding html tag.

Most large company websites that aren't simply static, video streaming (ex. youtube), or informational, will likely have the "X-Frame-Options" set to 'sameorigin'. This is known as a Frame-Killer, disabling iframes/frames/etc from embedding content because they are highly vulnerable to being Click-Jacked.

Check out the security section here in Dev Moz

Oftentimes, high profile companies with desirable endpoints and webpages will provide alternate embedding options or even API's that allow you to safely request access for displaying their resources.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.