完整错误是“无法在'DOMWindow'上执行'postMessage':提供的目标来源('https://www.youtube.com')与收件人窗口的来源('http://localhost:8100')不匹配。” ,这就是我在index.html文件中所做的,音频即将到来,但视频不是。
<script>
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Replace the 'ytplayer' element with an <iframe> and
// YouTube player after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('ytplayer', {
height: '390',
width: '640',
videoId: 'jdqsiFw74Jk'
});
}
</script>
另外,我想将视频ID从页面发送到index.html