The method of JS changing embed label SRC value

Source: Internet
Author: User

This paper illustrates the method of JS changing embed label SRC value. Share to everyone for your reference. The specific analysis is as follows:

Today there is a need for a bunch of videos, a bunch of links, click on the relevant links to open related videos on this page.

The first idea, very simple, directly to the SRC value into the click of the href value is OK.

Try the next, find this not good, video how release is put, always is just open that.

Second idea, to add a label outside the embed, the contents of the empty, and then write in, this can always be.

Try it, like the above, still not.

Tried a lot of similar methods, or not.

Finally, think, put the embed tag hidden (display:none), and then empty the test. It's finally ready!

The code is as follows:

1 2 3 4 5 6 7 8 9 A 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; } }
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.