如何防止嵌入的视频链接到另一个网页

How to prevent embedded video from linking to another web page

我的网页上有一个不是来自 youtube 或 vimeo 的嵌入视频。我希望观众只能观看我网页上的视频。如何防止点击视频时链接到另一个网页?我使用 CSS 属性 of pointer-events: none 来阻止视频链接到另一个网页,但现在视频不会在我的网页上播放。请帮忙。

<!DOCTYPE html>
<html>
<head>
<style>

iframe {
     pointer-events: none;
  }
</style>
</head>
<body>    
<iframe   src="http://flashservice.simplevideo.com/embedframe/18598" frameborder=0 width=510 height=400 scrolling=no allowfullscreen  ></iframe>   

</body>
</html>

iFrame 的 sandbox 属性应该是您要查找的内容。 例如:

<iframe src="http://flashservice.simplevideo.com/embedframe/18598"
frameborder=0 width=510 height=400 scrolling=no allowfullscreen 
sandbox="allow-same-origin allow-scripts"></iframe>

请注意,sandbox 属性充当白名单,因此如果不给它 allow-popupsallow-top-navigation 权限,它就无法打开新页面,也无法更改父网页!