Sadik Multani
Sadik Multani

Reputation: 131

Not able to show iframe in html

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?

Upvotes: 0

Views: 210

Answers (3)

Mr Sanders
Mr Sanders

Reputation: 1

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

Upvotes: 0

Jonas Johansson
Jonas Johansson

Reputation: 427

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 ;)

Upvotes: 1

Ibrahim Hasnat
Ibrahim Hasnat

Reputation: 955

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.

Upvotes: 2

Related Questions