Js Method for changing the src value of the embed label, jsembed label src
This article describes how to change the src value of the embed label in js. Share it with you for your reference. The specific analysis is as follows:
Today, we have a need for a bunch of videos, links, and links to open related videos on this page.
First, it's easy. Just change the src value to the href value you clicked on.
After trying, I found that this is not the case. How to put the video or how to put it? It will always be the one I just opened.
The second idea is to add a label to the embed, clear the content, and write it into it. This will always work.
I tried it. It is the same as above.
I tried many other similar methods, but I still cannot.
Finally, hide the embed label (display: none) and try again. Finally, you can!
The Code is as follows:
var tabv = document.getElementById("f_tabv");var tabva = tabv.getElementsByTagName("a");var tabcv = document.getElementById("f_tab_cv");tabcv.innerHTML = '<EMBED src="abc.wmv" autostart="true"width="545" height="325" type="video/x-ms-asf"></EMBED>';for(var i=0; i<tabva.length; i++){ tabva[i].onclick=function(){ var href1 = this.getAttribute("href"); var href2 = '<EMBED src="'+href1+'" autostart="true" width="545" height="325" type="video/x-ms-asf"></EMBED>'; tabcv.getElementsByTagName("embed")[0].style.display="none"; tabcv.innerHTML=""; tabcv.innerHTML=href2; for(i=0; i<tabva.length; i++){ tabva[i].className=''; } this.className = "act"; return false; }}
I hope this article will help you design javascript programs.