Reputation: 55710
On our website we will be allowing iframe
modules from other sites to display on our company's webpage. We want to use iframe
sandboxing to prevent these modules from doing anything crazy like phishing attacks, but I can't seem to find a way to prevent the iframe
from playing annoying audio.
<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>
Is this possible?
Upvotes: 1
Views: 2509
Reputation: 166
Looks like in FireFox it may be:
Updated link: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/mute_event
broken link: https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/mute
To save you the trouble of clicking the link:
The mute() method of the HTMLIFrameElement mutes any audio playing in the browser .
var browser = document.querySelector('iframe');
browser.mute();
Upvotes: 1