JavaScript function that alternates YouTube embed sources? (No iframe) -
the intention upon clicking button youtube video embed code (without iframe) generate youtube video embed code - here html:
<p><button onclick="philscode()">click here!</button></p> + <div id="video0"><embed src="https://www.youtube.com/v/dp_zpemrjxy" wmode="transparent" type="application/x-shockwave-flash" width="200px" height="140px" allowfullscreen="true"></div>
i need embedded youtube video (above) replaced youtube video. don't want have use jquery either. here javascript have currently:
<script> var embedcodes = ["https://www.youtube.com/watch?v=0vxq6k6ylm0"]; function philscode() {document.getelementbyid("video0").innerhtml = embedcodes [0]; </script>
here demo http://embed.plnkr.co/phmnaqd2jqa4rh8itk0i
<script> var embedcodes = ["http://www.youtube.com/v/xgsy3_czz8k"]; function philscode() { var el = document.getelementbyid("video0embed"); var clone=el.clonenode(true); clone.setattribute('src', embedcodes [0]); el .parentnode.replacechild(clone,el ); } </script> <p><button onclick="philscode()">click here!</button></p> <div id="video0"> <embed width="420" height="315" id="video0embed" src="https://www.youtube.com/v/dp_zpemrjxy"> </div>
Comments
Post a Comment