首页 > 解决方案 > 无法在 html 中显示 iframe

问题描述

我正在尝试添加iframe,但出现错误。这是我的代码:

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

代码笔: https ://codepen.io/multanisadik/pen/xxKmVeB

谁能帮我?

标签: htmlcss

解决方案


您不能在 iframe 中显示谷歌。大多数知名网站都屏蔽了这些功能。

原因是,他们发送了一个名为X-Frame-Options: SAMEORIGIN的响应头。此选项可防止浏览器显示 iframe。


推荐阅读