Problem with iframe

Asked

Viewed 229 times

-1

I try to open a simple link in an iframe, and it throws this error:

Refused to display in a frame because it set 'X-Frame-Options' to 'sameorigin'

This is the complete code:

<html>
  <head>
    <meta charset="utf-8" />
    <title>Testing Page</title>
  </head>
  <body>
    <iframe width="400" height="215" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.google.com"> </iframe><br />
  </body>
</html>
  • It can help you: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options

1 answer

2


There is nothing wrong with your code, the problem is the security of the server you are calling.

The site "google.com" defined that it cannot be opened in iframes of other domains other than "google.com".

To use an iframe you have to import a page your own, or from some less secure site such as bitbucket for example:

<html>
<head>
    <meta charset="utf-8" />
    <title>Testing Page</title>
</head>

    <body>
            <iframe width="400" height="215" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://bitbucket.com"> </iframe><br />
    </body>

</html>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.