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
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:
- How can I change back to the old Yahoo! home page?Best solution by Yahoo! Answers
- How can i put the 'Yahoo!" icon on my start page?Best solution by Yahoo! Answers
- How can I go back to my old MY Yahoo page?Best solution by Yahoo! Answers
- How can i get this music player on my myspace page?Best solution by Yahoo! Answers
- How can I get an audio alert when I get a new e-mail?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.