html - 无法嵌入 YouTube 视频(Cookie 错误 : samesite attribute)

标签 html flask

当我按下嵌入的 YouTube 视频播放时,我得到“视频不可用”。我在控制台中遇到的错误是:

A cookie associated with a cross-site resource at https://youtube.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
我的 HTML 代码如下:
<iframe width="560" height="315" src={{ embedURL }} frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
我也尝试过硬编码的嵌入链接,但它产生了相同的结果。我是否缺少标签中的属性?

最佳答案

您可以尝试使用 www.youtube-nocookie.com/embed/+视频 ID。
例如 https://www.youtube-nocookie.com/embed/N4Keb583jf0
小心,这是唯一应该一直有效的 URL 语法:您需要 www 和/embed/...
在您的代码中, embedurl 将是:https://www.youtube-nocookie.com/embed/+VideoID (+ 意思是“连接”)

关于html - 无法嵌入 YouTube 视频(Cookie 错误 : samesite attribute),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62984682/

相关文章:

javascript - 使用 jQuery 选择附加的链接按钮

jquery - 为什么 jQuery 不选择所有属性元素?

python - 在 Flask 中显示带换行符的文本字段

python - 需要在 Flask 中编写 View 函数的代码方面的帮助 - Python Web 框架

python - flask 返回存储在数据库中的图像

python - psycopg2.ProgrammingError : column cons. consrc 不存在

javascript - 循环遍历 html 表单

html - 我正在尝试为我的网站水平对齐文本和图像

javascript - 滚动数据时如何保持标题固定

python - Flask 子域与 Heroku 和 Godaddy(SERVER_NAME 问题)