Html iframe 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7947144/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Iframes not working
提问by Chris
I'm trying to get Iframes to work. I'm running safari, so it is compatible, but when I test it, it comes up blank. Code:
我正在尝试让 Iframe 工作。我正在运行 safari,所以它是兼容的,但是当我测试它时,它出现空白。代码:
<iframe src="http://www.google.com" width="100%" height="300">
<iframe src="http://www.google.com" width="100%" height="300">
<p>Your browser does not support iframes.</p>
<p>Your browser does not support iframes.</p>
</iframe>
</iframe>
I took the code directly from the w3schools website after using the "try it out" editor so I know it's supposed to work. When I changed the page from a page in their subdirectory to an external page, it shows up blank.
在使用“试用”编辑器后,我直接从 w3schools 网站获取了代码,所以我知道它应该可以工作。当我将页面从其子目录中的页面更改为外部页面时,它显示为空白。
回答by Pekka
The syntax is correct. It's not your fault - Google is blocking iframing using the X-Frame-Options
header that newer browsers listen to.
语法是正确的。这不是你的错 - 谷歌使用X-Frame-Options
较新的浏览器监听的标题来阻止 iframe 。
Possible workarounds are explained in this Google forum post.
此 Google 论坛帖子中说明了可能的解决方法。
回答by Antonio Jha
Follow the instruction in the following Google Developer Site under "IFrame embeds using the IFrame Player API" bullet: https://developers.google.com/youtube/player_parameters
按照以下 Google 开发者网站中“使用 IFrame Player API 嵌入 IFrame”项目符号中的说明进行操作:https: //developers.google.com/youtube/player_parameters
This uses API's JavaScript code to view youtube videos.
这使用 API 的 JavaScript 代码来查看 youtube 视频。
Here's the link with a more general instruction https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player
这是带有更一般说明的链接 https://developers.google.com/youtube/iframe_api_reference#Loading_a_Video_Player