Search
 
SCRIPT & CODE EXAMPLE
 

HTML

on button click video popup in html

<html>
<style>
.modal {
  display: none; 
  position: fixed;
  z-index: 1; 
  padding-top: 100px; 
  left: 0;
  top: 0;
  width: 100%;
  height: 100%; 
  overflow: auto;
  background-color: rgb(0,0,0);
  background-color: rgba(0,0,0,0.4); 
}
.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
}
.close {
  color: #aaaaaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}
</style>
<body>
       <h1>Contents of your page here</h1>
<button id="myBtn">Open Popup</button>

<!-- The Modal -->
<div id="myModal" class="modal">

  <!-- Modal content -->
  <div class="modal-content">
    <span class="close">&times;</span>
    <video controls>
    <source src="video source here">
    </video>
  </div>

</div>

<script>
// Get the modal
var modal = document.getElementById("myModal");

// Get the button that opens the modal
var btn = document.getElementById("myBtn");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks the button, open the modal 
btn.onclick = function() {
  modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
  modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
  if (event.target == modal) {
    modal.style.display = "none";
  }
}
</script>

       <h1>(This example works using the modal property in CSS)</h1>

</body>
</html>
Comment

onclick video popup in html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Video Popup</title>
    <style>
    #fade {
    display: none;
    position: fixed;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index: 1001;
    -moz-opacity: 0.8;
    opacity: .80;
    filter: alpha(opacity=80);
  }
  
  #light {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    max-width: 600px;
    max-height: 360px;
    margin-left: -300px;
    margin-top: -180px;
    border: 2px solid #FFF;
    background: #FFF;
    z-index: 1002;
    overflow: visible;
  }
  
  #boxclose {
    float: right;
    cursor: pointer;
    color: #fff;
    border: 1px solid #AEAEAE;
    border-radius: 3px;
    background: #222222;
    font-size: 31px;
    font-weight: bold;
    display: inline-block;
    line-height: 0px;
    padding: 11px 3px;
    position: absolute;
    right: 2px;
    top: 2px;
    z-index: 1002;
    opacity: 0.9;
  }
  
  .boxclose:before {
    content: "×";
  }
  
  #fade:hover ~ #boxclose {
    display:none;
  }
  
  .test:hover ~ .test2 {
    display: none;
  }
    </style>
</head>

<body>
    <h1>CSS/Javascript popup with Lightbox effect</h1>

    <div id="light">
        <a class="boxclose" id="boxclose" onclick="lightbox_close();"></a>
        <iframe id="VisaChipCardVideo" width="600" height="315" src="https://www.youtube.com/embed/HpaQQW_72ro"
            title="YouTube video player" frameborder="0"
            allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
            allowfullscreen></iframe>
    </div>

    <div id="fade" onClick="lightbox_close();"></div>

    <div>
        <a href="#" onclick="lightbox_open();">Watch video</a>
    </div>
    
    <script>
    window.document.onkeydown = function (e) {
    	if (!e) {
        	e = event;
    	}
    	if (e.keyCode == 27) {
        	lightbox_close();
    	}
	}

	function lightbox_open() {
    	var lightBoxVideo = document.getElementById("VisaChipCardVideo");
    	window.scrollTo(0, 0);
    	document.getElementById('light').style.display = 'block';
    	document.getElementById('fade').style.display = 'block';
    	lightBoxVideo.play();
	}

	function lightbox_close() {
    	var lightBoxVideo = document.getElementById("VisaChipCardVideo");
    	document.getElementById('light').style.display = 'none';
    	document.getElementById('fade').style.display = 'none';
    	lightBoxVideo.pause();
	}
    </script>
</body>

</html>
Comment

PREVIOUS NEXT
Code Example
Html :: a tag new page] 
Html :: agregar atributo jquery 
Html :: trash icon html 
Html :: show spinner during API request pure html and jquery 
Html :: meta property="og:description" 
Html :: free html dashboard templates 
Html :: how to make text uppercase html 
Html :: time input html 
Html :: embed github html 
Html :: bootstrap 5 navbar not working 
Html :: bootstrap hide row 
Html :: input type text inside select option 
Html :: how to accossate an id to html elemtnts 
Html :: oauth vs auth0 
Html :: laravel route regular expression constraints 
Html :: html login and registration form 
Html :: span href 
Html :: html js script 
Html :: invisible element html 
Html :: view html file linux terminal 
Html :: print view fields in unformatted.html.twig drupal 
Html :: img tag 
Html :: multiple checkbox in one line bootstrap 
Html :: bold font html 
Html :: superscript in html 
Html :: onchange html 
Html :: html ingnor display none input 
Html :: html show and hide div 
Html :: Disabled href tag 
Html :: html injection 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =