views:

47

answers:

2

I have a list of videos - On each video there is an onlick function - the onlick function should replace the value(URL) of the :

 <object width="640" height="385">
    <param name="movie" value="http://www.youtube.com/v/QmOkhayXlYw?fs=1&amp;amp;hl=da_DK"&gt;&lt;/param&gt;
    <param name="allowFullScreen" value="true"></param>
    <param name="allowscriptaccess" value="always"></param>
    <embed src="http://www.youtube.com/v/QmOkhayXlYw?fs=1&amp;amp;hl=da_DK" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed>
  </object>

So when clicking on a video in the list, the URL in value and src should be replaced with the new URL coming from the onlick function:

 <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)"&gt;
  <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>    
A: 

You can put the object tags in a div and the regenerate entire object tag (using div.innerHTML) in your onclick event.

VinayC
A: 
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);
}

Should work, however it would be best to use the youtube API like here: link text

red-X