Javascript 如何解决';未能执行';后消息';在';DOMWindow'';来自YouTube嵌入的错误
使用YouTube JavaScript/iFrame API,我试图寻找视频的不同时间 我已经将一个演示简化为: 如果在控制台中查看,您将看到以下错误:Javascript 如何解决';未能执行';后消息';在';DOMWindow'';来自YouTube嵌入的错误,javascript,youtube,youtube-api,youtube-javascript-api,postmessage,Javascript,Youtube,Youtube Api,Youtube Javascript Api,Postmessage,使用YouTube JavaScript/iFrame API,我试图寻找视频的不同时间 我已经将一个演示简化为: 如果在控制台中查看,您将看到以下错误: Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('http://jsbin.com').
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided
('https://www.youtube.com') does not match the recipient window's origin
('http://jsbin.com').
我需要解决这个问题才能开始使用JavaScript API,但我不确定如何修复它
更新:
我已经重新启动了我的计算机,但没有发生错误。如果我再次看到错误,我将进行更新。问题是,您正在使用纯HTTP传输的站点上进行测试,但您请求的是SSL版本的youtube API。我确实认为谷歌已经在他们的Youtube IFrame API JS中修复了这个问题,但使用它将是最优雅的:
tag.src=“//www.youtube.com/iframe\u api”代码>
而不是
tag.src=”https://www.youtube.com/iframe_api";代码>
自动选择与父协议相同的协议
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided
('https://www.youtube.com') does not match the recipient window's origin
('http://jsbin.com').