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