Js Method for changing the src value of the embed label, jsembed label src

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.