这是我得到的错误信息:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided
('https://www.youtube.com') does not match the recipient window's origin
('http://localhost:9000').
我见过其他类似的问题,其中目标源是http://www.youtube.com,收件人源是https://www.youtube.com,但没有一个像我的问题一样,目标是https://www.youtube.com,源是http://localhost:9000。
我不明白这个问题。有什么问题吗?
我该怎么解决呢?
它看起来只是一个Chrome安全系统,阻止重复请求,使用CORB。
https://www.chromestatus.com/feature/5629709824032768
在我的案例中,YouTube在第一次加载相同的网页后阻止访问,该网页有许多视频API数据请求,高负载。
对于负载较低的页面,则不会出现此问题。
在Safari和其他非基于Chronuim的浏览器中,不会出现此问题。
如果我在新的浏览器中加载网页,问题不会发生,当我重新加载同一页面时,问题就出现了。
扩展上面@Hokascha的回答,对我来说也是惰性加载,被WordPress自动添加。这段代码将删除站点iframes上的所有延迟加载(添加到functions.php):
function disable_post_content_iframe_lazy_loading( $default, $tag_name, $context ) {
if ( 'iframe' === $tag_name ) {
return false;
}
return $default;
}
add_filter('wp_lazy_loading_enabled', 'disable_post_content_iframe_lazy_loading', 10, 3);
只需要在播放器的paramVars属性中添加参数“origin”和你网站的URL,就像这样:
this.player = new window['YT'].Player('player', {
videoId: this.mediaid,
width: '100%',
playerVars: {
'autoplay': 1,
'controls': 0,
'autohide': 1,
'wmode': 'opaque',
'origin': 'http://localhost:8100'
},
}