skip to Main Content

I am trying to implement a embedded youTube link to a custom Html page and setting it to autoplay but as I open my Homepage video doesn’t play and only played when clicked .

<iframe width="1560" height="415" src="https://www.youtube.com/../?autoplay=1"
                            frameborder="0" allowfullscreen></iframe>

I want to make it responsive.

3

Answers


  1. I’m not sure if this helps or even works but have you tried something like this?

    $(document).ready(function() {
        $(iframe).click();
    });
    
    Login or Signup to reply.
  2. You said https://www.youtube.com/../?autoplay=1

    Get rid of that slash before the question mark

    I think it should be https://www.youtube.com/viddata?autoplay=1 instead.

    Maybe thats why its not playing

    Login or Signup to reply.
  3. Get rid of the slash in the URL like Coder2195 said (https://www.youtube.com/viddata?autoplay=1). Also try to add this script to the HTML file:

    <script>
    window.onload = function() {
      var videoElement = document.getElementById("videoElement");
      videoElement.click()
    }
    </script>
    

    And make the iframe element have a custom id:

    <iframe id="videoElement" width="1560" height="415" src="https://www.youtube.com/../?autoplay=1" frameborder="0" allowfullscreen></iframe>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search