14

当我在 HTML5 模式下使用 iframe api 将 youtube 嵌入 HTTPS 页面时,它仍然使用 HTTP 提取实际流,这会生成混合内容警告。是否正确支持此用例?

我从 2011 年发现这个讨论表明它不是。但是,我只是尝试使用 HTTPS 访问 CDN 服务器,它可以工作 - 有点 - 但它返回错误的证书(google.com 而不是 youtube.com 的东西)。

有没有人设法使用 HTML5 中的 IFRAME API 在 HTTPS 页面上嵌入视频而不会触发混合内容警告(即 Chrome 中带有黄色警告标志的锁)?

谢谢

4

2 回答 2

5

It seems that (as of October 2012) this is the expected behaviour and there are no plans to change it: https://code.google.com/p/gdata-issues/issues/detail?id=2964&can=1&q=youtube%20https&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary

于 2013-01-22T08:00:44.350 回答
0

您可以通过将 iframe API 脚本配置为如下所示来解决此问题。

使用 '//' 作为标签 src

var tag = document.createElement('script');
tag.src = "//www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var url = window.location.pathname; 

这将导致播放器使用与其嵌入页面相同的协议来加载资源。

于 2015-05-05T15:03:59.240 回答