Changes

Jump to navigation Jump to search
89 bytes added ,  18:58, 22 May 2023
no edit summary
Line 2: Line 2:  
<html>
 
<html>
 
   <head>
 
   <head>
     <title>YouTube Video Auto Play</title>
+
     <title>YouTube Video Click-to-Play</title>
 
   </head>
 
   </head>
 
   <body>
 
   <body>
     <div id="video-container"></div>
+
     <div id="video-container">
 +
      <button onclick="loadVideo()">Click to Play Video</button>
 +
    </div>
    
     <script>
 
     <script>
 
       function loadVideo() {
 
       function loadVideo() {
 
         var container = document.getElementById('video-container');
 
         var container = document.getElementById('video-container');
         var videoUrl = 'https://www.youtube.com/embed/efR1C6CvhmE?autoplay=1';
+
         var videoUrl = 'https://www.youtube.com/embed/efR1C6CvhmE';
    
         var iframe = document.createElement('iframe');
 
         var iframe = document.createElement('iframe');
Line 17: Line 19:  
         iframe.height = 240;
 
         iframe.height = 240;
 
         iframe.setAttribute('allow', 'autoplay');
 
         iframe.setAttribute('allow', 'autoplay');
 +
        container.innerHTML = ''; // Clear existing content
 
         container.appendChild(iframe);
 
         container.appendChild(iframe);
 
       }
 
       }
  −
      window.onload = loadVideo;
   
     </script>
 
     </script>
 
   </body>
 
   </body>
 
</html>
 
</html>
581

edits

Navigation menu