Steps :-
If you want to create popup on the click of a link then you need to follow the following steps.
1. Create link in you HTML file.
<div id="link">
<a href="javascript:openPopUp('http://makecodeeasy.blogspot.in/')">Click Here For open popUp</a>
</div>
2. Create a popUp by HTML and CSS.
<div id="popup" class="popUpDisplay">
<div class="popUpTitle">
<span onClick="closePopUp()"><img alt="Close Popup" src="close.png"/></span>
</div>
<div class="data">
<h3>Welcome to Make Code Easy </h3>
<br>
For getting more knowledge click on Continue
<ul class="buttons">
<li><span class="button" onclick="window.open(link), closePopUp()">Continue</span></li>
<li><span class="button" id="Cancel" onClick="closePopUp()">Cancel</span></li>
</ul>
</div>
</div>
3. Create CSS for divs
.popUpTitle {
background-color: #000000;
height: 40px;
width: 100%;
}
.popUpTitle img {
float: right;
margin-right: 2px;
margin-top: 5px;
}
.data {
background-color: #FFFFFF;
height: auto;
overflow: hidden;
font-size: 14px;
padding: 25px 25px 50px;
width: auto;
}
.buttons li {
cursor: pointer;
float: left;
height: 29px;
margin-right: 15px;
width: 134px;
}
span.button {
background-color: #000000;
color: #ffffff;
font-size: 15px;
font-weight: bold;
padding: 8px 25px;
text-align: center;
}
.popUpDisplay {
display: none;
position: absolute;
width: 440px;
height: 300px;
width: 440px;
left: 250px;
z-index: 1001;
}
.dimLayer {
display: none;
outline: 0px none;
height: 100%;
width: 100%;
background: #A9A9A9;
top: 0px;
left: 0px;
z-index: 900;
position: absolute;
opacity: 0.5;
filter: alpha(opacity=50);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
-khtml-opacity: 0.5;
-moz-opacity: 0.5;
}
4. Create Java Script methods
<script type="text/javascript">
var link;
var element;
function openPopUp(url)
{
link = url;
element = document.getElementById("background");
element.style.display = "block";
element = document.getElementById("popup");
element.style.display = "block";
}
function closePopUp()
{
element = document.getElementById("popup");
element.style.display = "none";
element = document.getElementById("background");
element.style.display = "none";
}
</script>
5. When you click on link then popup opens.
6. Download the full example for checking the output.
Download Full Example
If you want to create popup on the click of a link then you need to follow the following steps.
1. Create link in you HTML file.
<div id="link">
<a href="javascript:openPopUp('http://makecodeeasy.blogspot.in/')">Click Here For open popUp</a>
</div>
2. Create a popUp by HTML and CSS.
<div id="popup" class="popUpDisplay">
<div class="popUpTitle">
<span onClick="closePopUp()"><img alt="Close Popup" src="close.png"/></span>
</div>
<div class="data">
<h3>Welcome to Make Code Easy </h3>
<br>
For getting more knowledge click on Continue
<ul class="buttons">
<li><span class="button" onclick="window.open(link), closePopUp()">Continue</span></li>
<li><span class="button" id="Cancel" onClick="closePopUp()">Cancel</span></li>
</ul>
</div>
</div>
3. Create CSS for divs
.popUpTitle {
background-color: #000000;
height: 40px;
width: 100%;
}
.popUpTitle img {
float: right;
margin-right: 2px;
margin-top: 5px;
}
.data {
background-color: #FFFFFF;
height: auto;
overflow: hidden;
font-size: 14px;
padding: 25px 25px 50px;
width: auto;
}
.buttons li {
cursor: pointer;
float: left;
height: 29px;
margin-right: 15px;
width: 134px;
}
span.button {
background-color: #000000;
color: #ffffff;
font-size: 15px;
font-weight: bold;
padding: 8px 25px;
text-align: center;
}
.popUpDisplay {
display: none;
position: absolute;
width: 440px;
height: 300px;
width: 440px;
left: 250px;
z-index: 1001;
}
.dimLayer {
display: none;
outline: 0px none;
height: 100%;
width: 100%;
background: #A9A9A9;
top: 0px;
left: 0px;
z-index: 900;
position: absolute;
opacity: 0.5;
filter: alpha(opacity=50);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
-khtml-opacity: 0.5;
-moz-opacity: 0.5;
}
4. Create Java Script methods
<script type="text/javascript">
var link;
var element;
function openPopUp(url)
{
link = url;
element = document.getElementById("background");
element.style.display = "block";
element = document.getElementById("popup");
element.style.display = "block";
}
function closePopUp()
{
element = document.getElementById("popup");
element.style.display = "none";
element = document.getElementById("background");
element.style.display = "none";
}
</script>
5. When you click on link then popup opens.
6. Download the full example for checking the output.
Download Full Example