<!DOCTYPE html>
<html>
<head>
<style>
.ModalBox {
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);
}
.ModalData {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
color:orange;
font-size:18px;
font-weight:bold;
}
.Close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.Close:hover,
.Close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
</style>
</head>
<body>
<h2>Modal Box</h2>
<button id="Button">Open Modal</button>
<div id="modal" class="ModalBox">
<div class="ModalData">
<span class="Close">×</span>
<p>Hello TutorialsLink!</p>
</div>
</div>
<script>
var popupmodal = document.getElementById('modal');
var btn = document.getElementById("Button");
var close = document.getElementsByClassName("Close")[0];
btn.onclick = function() {
popupmodal.style.display = "block";
}
close.onclick = function() {
popupmodal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == popupmodal) {
popupmodal.style.display = "none";
}
}
</script>
</body>
</html>Program to implement Modal Box.

Nitin Pandit
With over 10 years of vast development experience with different technologies, Nitin Pandit is Microsoft certified Most Valued Professional (Microsoft MVP) with a rich skillset that includes developing and managing IT/Web-based applications in different technologies, such as – C#.NET, ADO.NET, LINQ to SQL, WCF, and ASP.NET 2.0/3.x/4.0, WCF, WPF, MVC 5.0 (Razor), and Silverlight, along with client-side programming techniques, like jQuery and AngularJS. Nitin possesses a Master’s degree in Computer Science and has been actively contributing to the development community for its betterment. He has written more than 100 blogs/articles and 3 eBooks on different technologies to help improve the knowledge of young technology professionals. He has trained more than one lakh students and professionals, as a speaker in workshops and AppFests, conducted in more than 25 universities in North India.
