Search code examples
javascriptiframemute

mute iframe not working not a youtube iframe


I have the following iframe

<iframe id="video"
src="http://173.236.41.86/iframe/nagsheadpier.html"   
frameborder="0" 
width="560px" 
height="420px" 
scrolling="no">
</iframe>

I tried to prevent all sound from coming from this iframe using

<script> 
    var myVid=document.getElementById('video'); 
    myVid.muted=true; 
</script> 

and other variation of this without any progress. Is there any way to do this and if not why. any input would be great.


Solution

  • Do you have the code for what's in the iframe? You might have to enable the javascript api on the youtube player (https://developers.google.com/youtube/js_api_reference).

    Also, if you're accessing your video from the parent frame, you'll have to target the child frame and postMessage something to it (or just do all of it in the child frame)