如何从嵌入代码中获取视频ID?

时间:2011-02-18 09:59:23

标签: javascript

我有两个div我想通过JavaScript从(div id =“main)的embed标签中获取视频ID 。之后我想用嵌入代码替换该ID(的div container)。

 <div id ="container">


     <object width="550" height="550">
          <param value="http://www.youtube.com/v/sIFYPQjYhv8&amp;rel=0&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" name="movie">
         <param value="transparent" name="wmode">
         <embed width="550" height="550" wmode="transparent" type="application/x-shockwave-flash" src="http://www.youtube.com/v/sIFYPQjYhv8&amp;rel=0&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1">
       </object>
< /div>

<div id="main">
<a id="displayText">
<object width="150" height="150">
 <param value="http://www.youtube.com/v/sIFYPQjYhv8&amp;rel=0&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1" name="movie">
  <param value="transparent" name="wmode">
 <embed width="150" height="150" wmode="transparent" type="application/x-shockwave-flash" src="http://www.youtube.com/v/sIFYPQjYhv8&amp;rel=0&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;border=1"></object>
  </a>
  </div>

实际上,当我点击任意时,<div id="main">中有5个视频,那个视频应该是<div id ="container">

1 个答案:

答案 0 :(得分:0)

尝试:

x = document.getElementByTag('div');

if(x.id =='main')

{

做任何事情

}

好的......

x = document.getElementByTag('param')

if(x.name =='movie')

{

name = x.value;

}