我的网页上有一个嵌入式视频,不是来自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>
答案 0 :(得分:0)
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-popups
或allow-top-navigation
权限,则无法打开新页面,也无法更改父网页!< / p>