Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 5th, 2012  |  syntax: None  |  size: 1.98 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Play selected video
  2. <script type="text/javascript">
  3. function playVideo(sourceId, targetId) {
  4.    if (typeof(sourceId)=='string') {sourceId=document.getElementById(sourceId);}
  5.    if (typeof(targetId)=='string') {targetId=document.getElementById(targetId);}
  6.    targetId.innerHTML=sourceId.innerHTML;
  7.    return false;
  8.  
  9.    }
  10.     </script>
  11. <video id="6" width="320" height="240" controls="controls"></video>
  12.  
  13. <video id="1" style="display: none;"width="320" height="240" controls="controls">
  14.   <source src="movie1.mp4" type="video/mp4" />
  15.   <source src="movie1.ogg" type="video/ogg" />
  16.   <source src="movie1.webm" type="video/webm" />
  17. Your browser does not support the video tag.
  18. </video>
  19. <video id="2" style="display: none;" width="320" height="240" controls="controls">
  20.   <source src="movie2.mp4" type="video/mp4" />
  21.   <source src="movie2.ogg" type="video/ogg" />
  22.   <source src="movie2.webm" type="video/webm" />
  23. Your browser does not support the video tag.
  24. </video>
  25.  
  26.  
  27. <a href="#" onclick='return playVideo("1","6")'>Play Video 1</a>
  28. <a href="#" onclick='return playVideo("2","6")'>Play Video 2</a>
  29.        
  30. <script type="text/javascript">
  31.     function playVideo(sourceId, targetId) {
  32.         if (typeof(sourceId)=='string') {sourceId=document.getElementById(sourceId);}
  33.         if (typeof(targetId)=='string') {targetId=document.getElementById(targetId);}
  34.         targetId.innerHTML=sourceId.innerHTML;
  35.         return false;
  36.     }
  37. </script>
  38.  
  39. <div id="6"></div>
  40.  
  41. <div id="1" style="display: none">
  42.     <video width="320" height="240" controls="controls">
  43.         <source src="movie1.mp4" type="video/mp4" />
  44.         Your browser does not support the video tag.
  45.     </video>
  46. </div>
  47.  
  48. <div id="2" style="display: none">
  49.     <video width="320" height="240" controls="controls">
  50.         <source src="movie2.avi" type="video/avi" />
  51.         Your browser does not support the video tag.
  52.     </video>
  53. </div>
  54.  
  55. <a href="#" onclick='return playVideo("1","6")'>Play Video 1</a>
  56. <a href="#" onclick='return playVideo("2","6")'>Play Video 2</a>