0

I am trying to add an iframe but getting an error. Here is my Code:

  <html>
    <head>
        <title>Adding Iframe</title>
    </head> 
    <body>
        <iframe src="https://www.google.com/" height="300px" width="100%" name="iframe_a" id="if1">
        </iframe>
    </body>
</html>

Codepen: https://codepen.io/multanisadik/pen/xxKmVeB

Can anyone help me?

3 Answers3

2

You can't show google in an iframe. Most of the well-known site block these features.

The reason for this, they sent a response header called X-Frame-Options: SAMEORIGIN. This option prevents the browser from displaying iframe.

Ibrahim Hasnat
  • 935
  • 1
  • 8
  • 16
1

You are not doing anything wrong actually.
Try with https://Wikipedia.com instead and it will work the reason it is not working for you is as the comment states and a more elaborate answer can be here:

https://stackoverflow.com/a/8700754/6445892

TLDR: google won’t allow you, try with another site and it will work ;)

Julian
  • 1,592
  • 1
  • 13
  • 33
Jonas Johansson
  • 417
  • 3
  • 8
0

The iframe tag isn't enabled for every website, some websites don not permit that kind of access. Google is one of them.