阻止弹出广告或任何其他广告在iframe中弹出

时间:2019-03-07 07:44:44

标签: javascript html

我尝试通过以下方式阻止弹出广告:

<div class="iframe">
   <iframe sandbox = "allow-forms allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation" src="https://www.youtube.com/embed/testing" ></iframe>
</div>

它曾经可以工作,但是现在他们可以检测到它,并且将禁止播放视频,并且在控制台中将引发错误:

  

在新窗口中阻止打开“ URL”,因为该请求是在未设置“允许弹出窗口”权限的沙盒框架中发出的。

还有其他解决方法吗?

1 个答案:

答案 0 :(得分:0)

我认为使用sandbox属性可以为您提供帮助。

<ifame src="#" sandbox="allow-scripts"></iframe>

这将帮助您运行javascript,但阻止所有类型的对话框