Embed tag dynamically changes the value of SRC and locally refreshes the JavaScript method for playing other videos

Source: Internet
Author: User

HTML code at the video:
<DivID= "Mod_player"class= "Mod_player">    <EmbedID= "Evideo"src= "Http://static.video.qq.com/TPout.swf?vid=d0110upcugq&auto=1"allowFullScreen= "true"Quality= "High"width= "650"Height= "472"Align= "Middle"allowscriptaccess= "Always"type= "Application/x-shockwave-flash">
</Div>

Click on the list on the right, refresh playback on the left, start the code:

 $ (document). Ready (function   () { Span style= "COLOR: #008000" >//  Click on a link to the right list, video playback toggle  $ (' #mod_videolist Li ') . Find (' a '). each (function   (i, Elem) {$ ( Span style= "COLOR: #0000ff" >this ). Click (function   () {$ ( ' #mod_player > Embed '). attr (' src ', $ (t           His ). attr (' href '  return  false         ;      });  // document.getelementbyid (' Evideo '). Play ();   

This can only switch embed src value, but does not switch playback (strange firefox can switch playback, the other browser can only change the SRC), is not triggered by the video play action, but because it is not HTML5 <video> tags, Embed tags cannot be used in the play () method with JS, so you can only think of other methods, as follows:

$ (document). Ready (function(){    //Click on one of the links on the right list to toggle video playback$ (' #mod_videolist Li '). Find (' a '). each (function(i, Elem) {$ ( This). Click (function(){           $(' #mod_player > Embed '). Remove (); varstr = ' <embed id= ' Evideo "src=" ' + $ ( This). attr (' href ') + ' "allowfullscreen=" true "quality=" High "width=" 650 "height=" 472 "align=" Middle "allowscriptaccess=" Always "type=" Application/x-shockwave-flash ">"; $(' #mod_player '). html (str); return false;    }); });});

By "destroying" the embed and then changing the dynamic value of the embed SRC, regenerate the embed, which will be compatible with all browsers.

Embed tag dynamically changes the value of SRC and locally refreshes the JavaScript method for playing other videos

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.