我试图在我的网站上嵌入一个Youtube视频,使用
iframe
标签但是,当使用Chrome时,控制台上会出现许多警告,例如:
Reading cookie in cross-site context will be blocked in future Chrome versions
我也在网上读到使用
iframe
由于安全原因不鼓励使用。
为了避免破坏更改和安全问题,我想知道除了添加一个
video
标签,因为据我所知,阻止外部cookie是不可能的。
这是我的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/dQw4w9WgXcQ?si=huEs0X_fKX95LMeh"
title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen
></iframe>
</body>
</html>
这是完整的警告日志:
Reading cookie in cross-site context will be blocked in future Chrome versions
Cookies with the SameSite=None; Secure and not Partitioned attributes that operate in cross-site contexts are third-party cookies. In future Chrome versions, reading third-party cookies will be blocked. This behavior protects user data from cross-site tracking.