【问题标题】:How to prevent embedded video from linking to another web page如何防止嵌入的视频链接到另一个网页
【发布时间】:2016-07-20 14:15:06
【问题描述】:

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

<!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>

【问题讨论】:

  • 分享您的视频网址,该网址无效

标签: html css video-streaming html5-video


【解决方案1】:

iFrames 的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权限,它不能打开一个新页面,也不能改变父网页!

【讨论】:

  • @CarlMax 然后请点击勾选接受我的回答 - 你这样做也获得了声誉!
猜你喜欢
  • 2012-07-02
  • 2020-05-30
  • 2011-06-14
  • 2013-04-08
  • 2018-08-03
  • 1970-01-01
  • 2012-12-28
  • 1970-01-01
  • 2012-11-05
相关资源
最近更新 更多