js changes the src value of the embed tag

  • 2020-05-27 04:22:04
  • OfStack

This example shows how js can change the src value of the embed tag. Share with you for your reference. The specific analysis is as follows:

Today we have 1 request, 1 pile of videos, 1 pile of links. Click the relevant link and open the relevant video on this page.

The first idea, is that easy? Just change the src value to the href value of the one you clicked on.

I tried it, and I found that it didn't work. How should I play the video or how should I play it?

The second idea is to put a label on the outside of embed, empty it out, and put it in.

Tried, and the above 1, still no good.

I tried a lot of similar methods, but it didn't work.

Finally, hide the embed tag (display:none) and try to empty it. Finally!

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++){
 var href1 = this.getAttribute("href");
 var href2 = '<EMBED src="'+href1+'" autostart="true"
 width="545" height="325" type="video/x-ms-asf"></EMBED>';
 for(i=0; i<tabva.length; i++){
 this.className = "act";
 return false;

I hope this article has been helpful to your javascript programming.