title: How to mute document sound by javascript
body: <p>I am using an advertising code that play a movie in <code>&lt;iframe&gt;</code> each  3 Minutes</p>
  
  <p>This sound annoying user, How could i mute it,</p>
  
  <p>I could not change in <code>&lt;iframe&gt;</code> body because of <code>CROSS-ORIGIN</code></p>
  
  <p>Have it a solution?</p>
  
  <p><strong>Selection source:</strong></p>
  
  <pre><code>&lt;div data-asm-done="1" class="asm_async_creative" data-asm-host="xxlmarketingsolution.adspirit.de" data-asm-params="pid=1" id="asmvi1" style="position:relative; width:610px; height:343px;"&gt;
  &lt;script src="//xxlmarketingsolution.adspirit.de/adscript.php?async=asmvi1&amp;amp;wpcn=asm29334x1466076618999&amp;amp;ref=http%3A%2F%2Ftv.spielenxxl.de%2F&amp;amp;swf=21&amp;amp;scx=1920&amp;amp;scy=1080&amp;amp;vis=4&amp;amp;tz=1466076619000&amp;amp;pid=1"&gt;&lt;/script&gt;&lt;ins id="asm_fls36x7558266y1466076621" style="display: inline-block; width: 610px; height: 343px; text-align: left;" class=""&gt;&lt;span id="asmspan_vastwrapper5192281" style="font-size: 1px; width: 1px; height: 1px; overflow: hidden; display: inline-block;" class="asm_flash"&gt;&lt;object data="http://cdn.adspirit.de/banner/advastwrapper.swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=21,0,0,0" id="adspiritflashvastwrapper5192281" type="application/x-shockwave-flash" height="1" width="1"&gt; &lt;param name="movie" value="http://cdn.adspirit.de/banner/advastwrapper.swf"&gt; &lt;param name="flashvars" value="path=http%3A%2F%2Fvideo-adserver.ibillboard.com%2FgetAd%3Ftagid%3Dee7891f6-4cc8-4155-d266-c2a0df3f0d65&amp;amp;id=adspiritflashvastwrapper5192281&amp;amp;player_id=adspiritflashvastwrapper5192281"&gt;  &lt;param name="quality" value="autohigh"&gt;  &lt;param name="transparency" value="yes"&gt;  &lt;param name="allowFullScreen" value="true"&gt;  &lt;param name="allowScriptAccess" value="always"&gt;  &lt;param name="allowNetworking" value="all"&gt;  &lt;param name="wmode" value="transparent"&gt;  &lt;param name="swLiveConnect" value="true"&gt;  &lt;embed src="http://cdn.adspirit.de/banner/advastwrapper.swf" flashvars="path=http%3A%2F%2Fvideo-adserver.ibillboard.com%2FgetAd%3Ftagid%3Dee7891f6-4cc8-4155-d266-c2a0df3f0d65&amp;amp;id=adspiritflashvastwrapper5192281&amp;amp;player_id=adspiritflashvastwrapper5192281" allownetworking="all" allowfullscreen="true" allowscriptaccess="always" name="adspiritflashvastwrapper5192281" transperency="yes" swliveconnect="true" quality="autohigh" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="transparent" menu="false" height="1" width="1"&gt; &lt;/object&gt;&lt;/span&gt;&lt;span id="asmspan_5192281_vpaid" style="font-size: 1px; width: 1px; height: 1px; overflow: hidden; display: none;" class="asm_flash"&gt;&lt;object data="http://cdn.adspirit.de/banner/advpaid.swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=21,0,0,0" id="adspiritflash5192281_vpaid" type="application/x-shockwave-flash" height="343" width="610"&gt; &lt;param name="movie" value="http://cdn.adspirit.de/banner/advpaid.swf"&gt; &lt;param name="flashvars" value="wmode=opaque&amp;amp;id=adspiritflash5192281_vpaid&amp;amp;player_id=adspiritflash5192281_vpaid"&gt;  &lt;param name="quality" value="autohigh"&gt;  &lt;param name="transparency" value="yes"&gt;  &lt;param name="allowFullScreen" value="true"&gt;  &lt;param name="allowScriptAccess" value="always"&gt;  &lt;param name="allowNetworking" value="all"&gt;  &lt;param name="wmode" value="opaque"&gt;  &lt;param name="swLiveConnect" value="true"&gt;  &lt;embed src="http://cdn.adspirit.de/banner/advpaid.swf" flashvars="wmode=opaque&amp;amp;id=adspiritflash5192281_vpaid&amp;amp;player_id=adspiritflash5192281_vpaid" allownetworking="all" allowfullscreen="true" allowscriptaccess="always" name="adspiritflash5192281_vpaid" transperency="yes" swliveconnect="true" quality="autohigh" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="opaque" menu="false" height="343" width="610"&gt; &lt;/object&gt;&lt;/span&gt;&lt;script src="http://cdn.adspirit.de/banner/vastwrapper_async.js" type="text/javascript"&gt;&lt;/script&gt;&lt;script src="http://cdn.adspirit.de/banner/vast_async.js" type="text/javascript"&gt;&lt;/script&gt;&lt;/ins&gt;&lt;span id="asmspan_5192281" style="font-size: 1px; overflow: hidden; width: 610px; height: 343px; position: absolute; left: 0px; top: 0px; z-index: 991919991; display: inline-block;" class="asm_flash"&gt;&lt;object data="http://cdn.adspirit.de/banner/admovie.swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=21,0,0,0" id="adspiritflash5192281" type="application/x-shockwave-flash" height="343" width="610"&gt; &lt;param name="movie" value="http://cdn.adspirit.de/banner/admovie.swf"&gt; &lt;param name="flashvars" value="&amp;amp;movie=http%3A%2F%2Fcdn.adspirit.de%2Fbanner%2F1x1.flv&amp;amp;clickurl=http%3A%2F%2Fxxlmarketingsolution.adspirit.de%2Fadclick.php%3Ftz%3D1466076621131449%3Bpid%3D1%3Bkid%3D30%3Bwmid%3D36%3Bwsid%3D4%3Buid%3D1%3Bord%3D1466076621&amp;amp;&amp;amp;fgcolor=0xFFFFFF&amp;amp;bgcolor=0xFFFFFF&amp;amp;txcolor=0xFFFFFF&amp;amp;volume=25&amp;amp;&amp;amp;MouseMovePlay=off&amp;amp;autoload=on&amp;amp;mute=off&amp;amp;MouseMoveSound=off&amp;amp;FLVmenu=off&amp;amp;autorewind=off&amp;amp;loop=off&amp;amp;muteonly=off&amp;amp;MuteButton=on&amp;amp;FLVzoom=on&amp;amp;FullscreenButton=off&amp;amp;runtime=off&amp;amp;MouseOutMute=off&amp;amp;replay=off&amp;amp;volumebar=on&amp;amp;PlayButton=off&amp;amp;clicktarget=_blank&amp;amp;clickJSFunction=window.plyr_5192281_click&amp;amp;stopJSFunction=window.plyr_5192281_stop&amp;amp;playJSFunction=window.plyr_5192281_play&amp;amp;timeJSFunction=window.plyr_5192281_time&amp;amp;pauseJSFunction=window.plyr_5192281_pause&amp;amp;errorJSFunction=window.plyr_5192281_error&amp;amp;rewindJSFunction=window.plyr_5192281_rewind&amp;amp;expandJSFunction=window.plyr_5192281_expand&amp;amp;collapseJSFunction=window.plyr_5192281_collapse&amp;amp;finishJSFunction=window.plyr_5192281_finish&amp;amp;volumeChangeJSFunction=window.plyr_5192281_volume&amp;amp;liveConnectName=adspiritflash5192281&amp;amp;positionJSFunction=window.plyr_5192281_getPos&amp;amp;&amp;amp;id=adspiritflash5192281&amp;amp;player_id=adspiritflash5192281"&gt;  &lt;param name="quality" value="autohigh"&gt;  &lt;param name="transparency" value="yes"&gt;  &lt;param name="allowFullScreen" value="true"&gt;  &lt;param name="allowScriptAccess" value="always"&gt;  &lt;param name="allowNetworking" value="all"&gt;  &lt;param name="wmode" value="transparent"&gt;  &lt;param name="swLiveConnect" value="true"&gt;  &lt;embed src="http://cdn.adspirit.de/banner/admovie.swf" flashvars="&amp;amp;movie=http%3A%2F%2Fcdn.adspirit.de%2Fbanner%2F1x1.flv&amp;amp;clickurl=http%3A%2F%2Fxxlmarketingsolution.adspirit.de%2Fadclick.php%3Ftz%3D1466076621131449%3Bpid%3D1%3Bkid%3D30%3Bwmid%3D36%3Bwsid%3D4%3Buid%3D1%3Bord%3D1466076621&amp;amp;&amp;amp;fgcolor=0xFFFFFF&amp;amp;bgcolor=0xFFFFFF&amp;amp;txcolor=0xFFFFFF&amp;amp;volume=25&amp;amp;&amp;amp;MouseMovePlay=off&amp;amp;autoload=on&amp;amp;mute=off&amp;amp;MouseMoveSound=off&amp;amp;FLVmenu=off&amp;amp;autorewind=off&amp;amp;loop=off&amp;amp;muteonly=off&amp;amp;MuteButton=on&amp;amp;FLVzoom=on&amp;amp;FullscreenButton=off&amp;amp;runtime=off&amp;amp;MouseOutMute=off&amp;amp;replay=off&amp;amp;volumebar=on&amp;amp;PlayButton=off&amp;amp;clicktarget=_blank&amp;amp;clickJSFunction=window.plyr_5192281_click&amp;amp;stopJSFunction=window.plyr_5192281_stop&amp;amp;playJSFunction=window.plyr_5192281_play&amp;amp;timeJSFunction=window.plyr_5192281_time&amp;amp;pauseJSFunction=window.plyr_5192281_pause&amp;amp;errorJSFunction=window.plyr_5192281_error&amp;amp;rewindJSFunction=window.plyr_5192281_rewind&amp;amp;expandJSFunction=window.plyr_5192281_expand&amp;amp;collapseJSFunction=window.plyr_5192281_collapse&amp;amp;finishJSFunction=window.plyr_5192281_finish&amp;amp;volumeChangeJSFunction=window.plyr_5192281_volume&amp;amp;liveConnectName=adspiritflash5192281&amp;amp;positionJSFunction=window.plyr_5192281_getPos&amp;amp;&amp;amp;id=adspiritflash5192281&amp;amp;player_id=adspiritflash5192281" allownetworking="all" allowfullscreen="true" allowscriptaccess="always" name="adspiritflash5192281" transperency="yes" swliveconnect="true" quality="autohigh" type="application/x-shockwave-flash" pluginspage="https://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" wmode="transparent" menu="false" height="343" width="610"&gt; &lt;/object&gt;&lt;/span&gt;&lt;div style="position: absolute; left: 0px; top: 0px; width: 610px; height: 343px; z-index: 999189188; display: none;" id="asmspan_5192281_asmx"&gt;&lt;a href="#" onclick="window.asmvi1_vast.showAd(true,true); return false"&gt;&lt;img alt="" src="" border="0" height="343" width="610"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="position: absolute; left: 0px; top: 0px; z-index: 999189188; display: none; padding: 5px 10px; border-bottom: 1px solid white; border-right: 1px solid white; background-color: rgb(202, 221, 236);" id="asmspan_5192281_skipper"&gt;&lt;a style="font-size:11pt; color:black; font-family:Arial; line-height:1em; text-decoration:none;" href="#" onclick="window.asmvi1_vast.skipAd(); return false"&gt;Skip »&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
  
  &lt;script type="text/javascript" language="JavaScript"&gt;
  
  &lt;!--
  
  var asmvi_id = "asmvi1";
  
  var vastparam = new Object();
  
  vastparam.width = 610;
  
  vastparam.height = 343;
  
  vastparam.left = 0;
  
  vastparam.top = 0;
  
  vastparam.events = new Object();
  
  vastparam.events.AdLoaded = "";
  
  vastparam.events.AdStarted = "";
  
  vastparam.events.AdStopped = "";
  
  vastparam.events.AdExpandedChange = "";
  
  vastparam.events.AdRemainingTimeChange = "";
  
  vastparam.events.AdVolumeChange = "";
  
  vastparam.events.AdImpression = "";
  
  vastparam.events.AdVideoStart = "";
  
  vastparam.events.AdVideoFirstQuartile = "";
  
  vastparam.events.AdVideoMidpoint = "";
  
  vastparam.events.AdVideoThirdQuartile = "";
  
  vastparam.events.AdVideoComplete = "ausblenden_ext";
  
  vastparam.events.AdClickThru = "";
  
  vastparam.events.AdPaused = "";
  
  vastparam.events.AdPlaying = "";
  
  --&gt;
  
  &lt;/script&gt;
  
  &lt;script src="http://xxlmarketingsolution.adspirit.de/adasync.js" async="" type="text/javascript" language="JavaScript"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript" language="JavaScript"&gt;
  /* Ausblenden des Werbeframes */
  function ausblenden_ext()
      {
      document.domain = 'spielenxxl.de'; 
      window.parent.document.getElementById("werbevideo").style.display = 'none';
      }
  &lt;/script&gt;
  
  &lt;script&gt;
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  
    ga('create', 'UA-41585143-17', 'auto');
    ga('send', 'pageview');
  
  &lt;/script&gt;
  </code></pre>
  
  <p>What i have tried:</p>
  
  <pre><code>&lt;script&gt;
  var myini = setInterval(function(){
  var embeds = document.getElementsByTagName('embed');
  if(embeds){
  for (var i = 0; i &lt; embeds.length; i++) {
          embeds[i].setAttribute("flashvars", embeds[i].getAttribute("flashvars").replace("mute=off", "mute=on").replace("volume=25", "volume=0"));
          embeds[i].setAttribute("src", embeds[i].getAttribute("src"));
  }
  clearInterval(myini);
  }
  //.replace("mute=off", "mute=on").replace("volume=25", "volume=0");
  }, 200);
  &lt;/script&gt;
  </code></pre>