The following is a simple JavaScript pop-up code example.

HTML code:

<!-- Open pop-up button -->
<button id="myBtn">Open the pop-up window</button>
 
<!-- Pop-up window -->
<div id="myModal" class="modal">
 
   <!-- The content of the pop-up window -->
   <div class="modal-content">
     <span class="close">&times;</span>
     <p>The text in the pop-up window...</p>
   </div>
 
</div>

CSS code:

/* Popup (background) */
.modal {
     display: none; /* hidden by default */
     position: fixed; /* fixed positioning */
     z-index: 1; /* Set at the top level */
     left: 0;
     top: 0;
     width: 100%;
     height: 100%;
     overflow: auto;
     background-color: rgb(0,0,0);
     background-color: rgba(0,0,0,0.4);
}
 
/* The content of the pop-up window */
.modal-content {
     background-color: #fefefe;
     margin: 15% auto;
     padding: 20px;
     border: 1px solid #888;
     width: 80%;
}
 
/* Close button */
.close {
     color: #aaa;
     float: right;
     font-size: 28px;
     font-weight: bold;
}
 
.close:hover,
.close:focus {
     color: black;
     text-decoration: none;
     cursor: pointer;
}

JavaScript code:

// Get the pop-up window
var modal = document.getElementById('myModal');
 
// Open the button object of the pop-up window
var btn = document.getElementById("myBtn");
 
// Get the <span> element, used to close the pop-up window
var span = document.querySelector('.close');
 
// Click the button to open the pop-up window
btn.onclick = function() {
     modal.style.display = "block";
}
 
// Click <span> (x) to close the pop-up window
span.onclick = function() {
     modal.style.display = "none";
}
 
// When the user clicks elsewhere, close the pop-up window
window.onclick = function(event) {
     if (event.target == modal) {
         modal.style.display = "none";
     }
}

Online demo


Pop-up window to add head and bottom

HTML code:

<!-- Open pop-up button -->
pop-ups open <button id="myBtn"</button> >
 
<!-- Pop-up window -- >
<div id="myModal" class="modal">
 
<!-- Pop-up contents -- >
    <div class="modal-content">
      <div class="modal-header">
        <span class="close">&times;</span>
        <h2>Pop-up head</h2>
      </div>
      <div class="modal-body">
        <p> pop-up text...</p>
        <p> pop-up text...</p>
      </div>
      <div class="modal-footer">
        <h3>Bottom of the pop-up window</h3>
      </div>
    </div>
 
</div>

CSS code:

/* Background */
.modal {
    display: none; /* Hidden by default */
    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);
}
 
/* Pop-up content */
.modal-content {
    position: relative;
    background-color: #fefefe;
    margin: auto;
    padding: 0;
    border: 1px solid #888;
    width: 80%;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
    -webkit-animation-name: animatetop;
    -webkit-animation-duration: 0.4s;
    animation-name: animatetop;
    animation-duration: 0.4s
}
 
/* Add Animation */
@-webkit-keyframes animatetop {
    from {top:-300px; opacity:0} 
    to {top:0; opacity:1}
}
 
@keyframes animatetop {
    from {top:-300px; opacity:0}
    to {top:0; opacity:1}
}
 
/* Close button */
.close {
    color: white;
    float: right;
    font-size: 28px;
    font-weight: bold;
}
.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}
 
.modal-header {
    padding: 2px 16px;
    background-color: #5cb85c;
    color: white;
}
 
.modal-body {padding: 2px 16px;}
 
.modal-footer {
    padding: 2px 16px;
    background-color: #5cb85c;
    color: white;
}

Online demo


Pop-up window displayed at the bottom