如何在iframe中屏蔽弹出式广告,横幅广告和视频广告? [英] How to block pop-up, banner ads and video ads in iframe?

查看:539
本文介绍了如何在iframe中屏蔽弹出式广告,横幅广告和视频广告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在嵌入包含退出弹出式横幅广告和视频广告的视频。当您在视频中的任何位置
时,弹出窗口会自动打开,或者如何点击 X 图标来关闭横幅广告。

I'm embedding video that has an exit pop-up banner ads and video ads. When you anywhere in video then popups open automatic or how to click on X icon to close banner ad.

.iframe{
  width: 100%;
  float: left;
  margin-top: 5px;
}

<div class="iframe">
   <iframe width="1000" height="600" src="https://www.youtube.com/embed/Sb_60g3u1LU" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>
</div>

我正在使用其他第三方网站托管视频,如vidzi.tv& openload.co和这些网站充满了视频播放器中的弹出窗口和横幅广告。

I am using other third party websites to host videos like vidzi.tv & openload.co and these sites are full with pop ups and banner ads in video player.

推荐答案

您可以在iframe中添加 sandbox 属性。仅允许您添加到属性的值。浏览器不允许在沙箱属性中添加任何值。

You can add sandbox attribute in your iframe. Only the values you add to the attribute will be allowed. Any value you do not add in the sandbox attribute will not be allowed by browser.

沙盒属性具有以下值:

allow-forms
allow-pointer-lock
allow-popups
allow-same-origin
allow-scripts
allow-top-navigation

我有修改了您的代码以包含沙盒选项,但未添加 allow-popups ,因此此iframe中不允许弹出窗口。

I have modified your code to include sandbox option, but have NOT added allow-popups, so popups will not be allowed in this iframe.

<div class="iframe">
   <iframe sandbox = "allow-forms allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation" width="1000" height="600" src="https://www.youtube.com/embed/Sb_60g3u1LU" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>
</div>

您可以找到有关沙箱属性的更多信息此处。请注意,此属性是HTML5中的新属性。

You can find more about sandbox attribute here. Please note that this attribute is new in HTML5.

这篇关于如何在iframe中屏蔽弹出式广告,横幅广告和视频广告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆