如何使用此javascript显示youtube视频ID

时间:2013-03-11 21:21:53

标签: javascript youtube

我正在使用this javascript在我的网页上显示youtube搜索结果。

这是代码中显示标题,描述等的部分......

li.innerHTML = '<table cellspacing="0" cellpadding="0" border="0">
<tr><td valign="top" rowspan="2"></td>
<td valign="top"><h3>'+entry.title+'</h3><span>'+this.formatDescription(entry.description)+'</span></td>
<td valign="top" style="width: 150px" class="meta">
<div>From: <a href="http://www.youtube.com/profile?user='+entry.uploader+'">'+entry.uploader+'</a></div><div>Views: '+entry.viewCount+'</div><div>'+this.formatRating(entry.rating,entry.ratingCount)+' ratings</div>Time: '+this.formatDuration(entry.duration)+'</td></tr></table>';

如何在javascript中添加'+ytPlayerParams.videoId+''+data.id+'或其他内容,以便显示YouTube视频ID http://www.youtube.com/embed/...

1 个答案:

答案 0 :(得分:0)

li.innerHTML = '<table cellspacing="0" cellpadding="0" border="0">
  <tr><td valign="top" rowspan="2"></td>
    <td valign="top">
       <h3>'+entry.title+'</h3
       <span>'+this.formatDescription(entry.description)+'</span>
    </td>
    <td valign="top" style="width: 150px" class="meta">
      <div>From: <a href="http://www.youtube.com/profile?user='+entry.uploader+'">'+entry.uploader+'</a></div>
      <div>ID: '+entry.id+'</div><div>Views: '+entry.viewCount+'</div><div>'+this.formatRating(entry.rating,entry.ratingCount)+' ratings</div>
      Time: '+this.formatDuration(entry.duration)+'
      </td>
    </tr>
  </table>';

我为id添加了一个div,它将提供唯一的视频ID