阻止iframe播放音频

时间:2014-06-30 20:26:55

标签: html iframe

在我们的网站上,我们将允许来自其他网站的iframe个模块显示在我们公司的网页上。我们希望使用iframe sandboxing来防止这些模块像网络钓鱼攻击一样疯狂,但我似乎无法找到阻止iframe播放烦人音频的方法

<iframe sandbox=''>
  // Code from other site injected here
  // May contain something like this: <audio src='...' autoplay='true' />
  // May play sound some other way
  // Don't let any sound come out of this iframe!
</iframe>

这可能吗?

1 个答案:

答案 0 :(得分:1)

在FireFox中看起来可能是: https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/mute

为您省去点击链接的麻烦:

HTMLIFrameElement的mute()方法会将浏览器中播放的任何音频静音。

var browser = document.querySelector('iframe');

browser.mute();
相关问题