How to embed (almost) any document to HTML?

How can I mute the audio source of an html page embedded in an iframe?

  • I am working on a gallery page with quite a few external HTML  pages embedded using iframe, however, some of these external pages have  audio embedded into them which I would like to mute. Here is a sample code for the HTML files:- gallery.html <div id="pages">        <iframe id="embed" src="https://xyz.com/page1.html"></iframe>        <iframe id="embed" src="https://sdf.com/page2.html"></iframe> </div> page1.html <html>     <head>         <!-- head stuff-->     </head>     <body>         <audio autoplay>             <source src="http://audio.url/somefile.ogg" type="audio/ogg">             <source src="http://audio.url/somefile.mp3" type="audio/mpeg">             Your browser does not support the audio tag.         </audio>         <!--some more body content>     <body> </html> Also, since I'm dealing with multiple external pages, the audio tags mostly might not have ids attached to them. This makes "document.getElementById()" a non-reliable option. I've  experimented with "document.getElementsByTagName("input")" but couldn't quite get the audio muted. I've also tried "document.getElementsByTagName("audio").muted = true;" but this method also seems to fail.

  • Answer:

    i am aso having the same mute problem in my website http://malimian.host56.com/

Ali Mian at Quora Visit the source

Was this solution helpful to you?

Other answers

You won't be able to mute the external audio because browsers prevent you from inspecting/interacting with the DOM of embedded pages (for security reasons).  Calling document.getElementsByTagName didn't work because that only queries the main document, not the embedded documents. The only real solution I can think of is to write a proxy in a server-side language and embed the pages via your proxy.  You can write the proxy so that it strips out audio tags.

John Kurlak

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.