Skip to content Skip to sidebar Skip to footer

Stop All Audio Inside Iframes From Parent

I have one index.html that has several iframes in it. I am loading a different html page into each iframe when the index.html is launched. Each html page has multiple audio tags

Solution 1:

Something like this should do.
It should iterates all frames to find the audios.
Try it.

var frames = window.frames;
for (var i = 0; i < frames.length; i++) { 
  var sounds = frames[i].document.getElementsByTagName('audio');
  for(j=0; j<sounds.length; j++){
    sounds[j].pause();
  }
}

Post a Comment for "Stop All Audio Inside Iframes From Parent"