admin管理员组

文章数量:1420606

I want to add this video on my website. I added this code but it’s not working. Please help me.

<div id="container">
  <iframe id="vid" width="560" height="315" src=";noredirect=1" frameborder="0" allowfullscreen></iframe>
</div>
<style>
#container {
    border: 1px solid red;
    width: 560px;
    text-align: center;
}
#vid {
    margin-bottom: 25px;   
}
</style>

I want to add this video on my website. I added this code but it’s not working. Please help me.

<div id="container">
  <iframe id="vid" width="560" height="315" src="https://www.youtube./watch?v=NhxVR2Szu3k&noredirect=1" frameborder="0" allowfullscreen></iframe>
</div>
<style>
#container {
    border: 1px solid red;
    width: 560px;
    text-align: center;
}
#vid {
    margin-bottom: 25px;   
}
</style>
Share Improve this question edited Aug 14, 2015 at 6:23 Sebastian Simon 19.6k8 gold badges61 silver badges84 bronze badges asked Aug 14, 2015 at 6:17 user6930268user6930268 3
  • video not displaying – user6930268 Commented Aug 14, 2015 at 6:19
  • please check the code – user6930268 Commented Aug 14, 2015 at 6:21
  • it's worth mentioning that frameborder is a deprecated attribute check it here. You can use border: none instead – Jood80 Commented Jan 17, 2023 at 12:20
Add a ment  | 

2 Answers 2

Reset to default 4

UPDATED Please replace this with your code

<div id="container">
  <iframe width="560" height="315" src="https://www.youtube./embed/NhxVR2Szu3k" frameborder="0" allowfullscreen></iframe>
</div>

and css

#container {
    border: 1px solid red;
    text-align:center;
    width: 80%;
    margin-left:auto;
    margin-right:auto;
}

as you are not using correct code for video..go in video link..then share and then embed code and take that code and it will work..hope this help.

Updated : now your video is responsive..change width according to your need.

I didn't clearly understand what you're trying to achieve but try this example:

<html>
<head> </head>
<body>  
            <div style="text-align:center"> 
              <button onclick="playPause()">Play/Pause </button> 
              <br> 
              <video id="video" width="420">
                <source src="video.mp4" type="video/mp4">
                Your browser does not support HTML5 video.
              </video>
            </div> 
            
            <script> 
            var myVideo = document.getElementById("video "); 
            
            function playPause() { 
                if (myVideo.paused) 
                    myVideo.play(); 
                else 
                    myVideo.pause(); 
            } 
            </script>               
</body>
</html>

本文标签: javascriptWhy is this embedded iframe video not playingStack Overflow