【发布时间】:2019-06-03 18:38:22
【问题描述】:
目前,我正在研究放大嵌入的 youtube 视频的可能性。因此,我在 iframe 中设置了一个播放器(为此我使用 popcorn.js HTMLYoutubeElement)
player = new YT.Player( elem, {
width: "100%",
height: "100%",
wmode: playerVars.wmode,
videoId: aSrc,
playerVars: playerVars,
events: {
'onReady': onPlayerReady,
'onError': onPlayerError,
'onStateChange': onPlayerStateChange
}
});
出于我的目的,我想通过这个 iframe 访问 <video> 元素。
使用 youtube iframe API,我通过 player.getIframe() 获得了适当的 iframe。但是一旦我尝试使用例如获取“内部”文档
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
我收到以下错误消息:
Uncaught SecurityError: Blocked a frame with origin http://localhost:3000 from access cross-origin frame。
This kind of error is discussed here but without helping alot with my specific problem.
查看 youtube iframe API,我找不到任何直接访问 <video> 元素的可能性。因此我的问题是:这真的可能吗?
【问题讨论】:
-
出于安全原因,这是不可能的。
标签: javascript html youtube youtube-api youtube-iframe-api