Advertisement
Gloorian

Untitled

Oct 29th, 2011
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.82 KB | None | 0 0
  1. <!-- Partie html -->
  2.  
  3. <input type="button" id="el" value="Flash activé"/><br />
  4. <p id="flash" style="display:block;">
  5.     <object width="620" height="465">
  6.         <param name="movie" value="http://www.youtube.com/v/pP6epLQEI8I?version=3&feature=oembed">
  7.         <param name="allowFullScreen" value="true">
  8.         <param name="allowscriptaccess" value="always">
  9.         <embed src="http://www.youtube.com/v/pP6epLQEI8I?version=3&feature=oembed" type="application/x-shockwave-flash" width="620" height="465" allowscriptaccess="always" allowfullscreen="true">
  10.     </object>
  11. </p>
  12. <p id="html5" style="display:none;">
  13.     <video width="620" height="465" controls="controls">
  14.         <source src="video.mp4" type="video/mp4" />
  15.         <!--<source src="video.webm" type="video/webm" />
  16.         <source src="video.ogv" type="video/ogg" /> -->
  17.             Ici l'alternative à la vidéo : un lien de téléchargement, un message, etc.
  18.     </video>
  19. </p>
  20. <!-- Il vaudrait mieux ajouter ça dans un .htaccess si ce n'est pas fait:
  21.     AddType video/ogg  .ogv
  22.     AddType video/mp4  .mp4
  23.     AddType video/webm .webm
  24. -->
  25. <script type="text/javascript">
  26.    
  27.     var el = document.getElementById('el');
  28.     var el_flash = document.getElementById('flash');
  29.     var el_html5 = document.getElementById('html5');
  30.    
  31.     //on crée la fonction
  32.     var fonction = function() {
  33.         if(el_flash.style.display = 'block') //si flash est affiché
  34.         {
  35.             el_flash.style.display = 'none'; //on le fait disparaître et on affiche html5
  36.             el_html5.style.display = 'block';
  37.             el.value = 'html5 activé';
  38.         }
  39.         else if(el_flash.style.display = 'none'); //si flash n'est pas affiché
  40.         {
  41.             el_flash.style.display = 'block'; //on l'affiche et on fait disparaître html5
  42.             el_html5.style.display = 'none';
  43.             el.value = 'Flash activé';
  44.         }
  45.     };
  46.      //on crée l'évenement
  47.     el.addEventListener('click', fonction, false);
  48. </script>
  49.        
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement