-1

I am trying to open a https website from a html iframe but I am not able to do so. The code I am using is -<iframe style="min-height:98vh" src="https://www.google.com" width="100%"></iframe>

How can I do this?

  • You can't open google.com in an iframe period. It sets a header that tells the browser to disallow using in an iframe. – gman Feb 27 '20 at 06:44
  • This is a security concern , to quote the error. `Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource `. It is highly recommended not try to access another domain from one's domain. It can end up in high vulnarebility – Aravind Anil Feb 27 '20 at 06:44
  • duplicate question: https://stackoverflow.com/questions/8700636/how-to-show-google-com-in-an-iframe This has already required answer for you. – smnth90 Feb 27 '20 at 06:47

1 Answers1

0

If you want to open a site that is over 'https', you can use it like the code below.

<!DOCTYPE html>
<html>
<body>

<h2>HTML Iframes</h2>
<p>You can also use the CSS height and width properties to specify the size of the iframe:</p>

<iframe src="https://www.kuflink.com" style="height:250px;width:100%"></iframe>
<iframe src="https://www.flipkart.com" style="height:250px;width:100%"></iframe>
</body>
</html>

Now if you can see the first site is loaded into an iFrame, even if it is with https but the second one gets a connection refused. even if you try w3schools in an iframe it will do the same. You can inspect your code and post the error that you are getting. This I think will be of X-frame options. You can read furthermore here for X-Frame-Options

Heena Vora
  • 300
  • 4
  • 16
  • You can also look for best practices. https://security.stackexchange.com/questions/121800/https-iframe-embedded-in-http-page-pci-implications – Heena Vora Feb 27 '20 at 07:04