0

我正在使用这个 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 视频 IDhttp://www.youtube.com/embed/...

4

1 回答 1

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

于 2013-10-15T19:34:36.270 回答