我有一个视频列表 - 在每个视频上都有一个onlick功能 - onlick功能应该替换:
的值(URL) <object width="640" height="385">
<param name="movie" value="http://www.youtube.com/v/QmOkhayXlYw?fs=1&hl=da_DK"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/QmOkhayXlYw?fs=1&hl=da_DK" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed>
</object>
因此,当点击列表中的视频时,值和src中的URL应替换为来自onlick函数的新URL:
<xsl:variable name="XMLvideoID">
<xsl:value-of select="id"/>
</xsl:variable>
<xsl:variable name="videoId">
<xsl:value-of select="substring-after('$XMLvideoID','videos/')"/>
</xsl:variable>
<div class="video" onclick="playYouTubeVideo(http://www.youtube.com/v/{$videoId}?fs=1)">
<div class="thumb">
<img src="http://i.ytimg.com/vi/{$videoId}/2.jpg" height="90" width="120" alt="" title="" border="" />
</div>
<div class="info">
<div class="title">
<xsl:value-of select="title" disable-output-escaping="yes"/>
</div>
</div>
</div>
答案 0 :(得分:0)
您可以将对象标记放在div中,并在onclick事件中重新生成整个对象标记(使用div.innerHTML)。
答案 1 :(得分:0)
function playYouTubeVideo(link){
var videoHtml = "<object width=\"640\" height=\"385\">" +
"<param name=\"movie\" value=\"" + link + "\"><\/param>" +
"<param name=\"allowFullScreen\" value=\"true\"><\/param>" +
"<param name=\"allowscriptaccess\" value=\"always\"><\/param>" +
"<embed src=\"" + link + "\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"640\" height=\"385\"><\/embed>" +
"<\/object>";
$('#divcontainingthevid').html(videoHtml);
}
应该可行,但最好像这里一样使用youtube API: link text