我的网站页面中有一个视频iframe,我正在使用youtube和vimeo视频,并在完成视频时更改iframe src。
我的代码是:
<script src="http://www.youtube.com/player_api"></script>
<script src="https://f.vimeocdn.com/js/froogaloop2.min.js"></script>
function onYouTubePlayerAPIReady()
{
player = new YT.Player('video_player', {
events: {
'onStateChange': changeVideoSrc,
'onReady': onPlayerReady
}
});
}
function changeVideoSrc()
{
// here changing the iframe src
}
$('#main iframe').load(function() {
var iframe = $('#video_player');
var player = $f(iframe);
player.addEvent('ready', function() {
player.addEvent('finish', onFinish);
});
function onFinish(id)
{
// here changing the iframe src
}
});
一切正常,但在控制台中,更改iframe src时会产生错误:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('https://player.vimeo.com').
我还尝试添加vimeo
message
事件监听器,但它对我不起作用。
如何从控制台中删除此错误?