Sometimes you may be required to have popup windows on your website. They're obtrusive and hard to style with your site, in summary – nasty. What I've seen is other websites fade out their background and have an in page popup. I came up with a script that does the same thing in PHP.
Now the code involves multiple parts so bare with me here. Either way your end product will look like the image below.

Lets start with the CSS here. Just copy and paste this into your CSS file or HTML.
html {
height: 100%;
}
.fade_container {
width: 100%;
height: 100%;
min-height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 100000;
overflow: hidden;
}
.fade {
width: 100%;
height: 100%;
min-height: 100%;
background: #000;
position: absolute;
top: 0;
left: 0;
z-index: 110000;
overflow: hidden;
}
.popup {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
padding: 4px;
position: absolute;
left: 50%;
top: 100px;
z-index: 150000;
}
.popup_close {
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
padding: 2px;
margin-bottom: 5px;
background: #CCC;
text-align: right;
}
.popup_close a:link, .popup_close a:visited, .popup_close a:hover, .popup_close a:active {
color: #333;
text-decoration: none;
}
</style>
There's really no need to edit anything unless you want to change the font and stuff, the colors will be modified later. The next part you have to add this code right after your <body> tag.
//In Page Popup Box with Faded Background by Jerry Low @crankberryblog.com
//Find other useful scripts at the Crankberry Blog
//SETTINGS
$fade_amount = 60; //In Percentage
$box_width = 400;
$box_background = 'FFFFFF'; //Hex Color
$box_border_width = 1;
$box_border_color = '999999'; //Hex Color
$close_box = 1; //Do You Want The Close Bar on Top 1 = Yes, 0 = No
$extension = ""; // Other Variables that maybe needed, page number etc.
//Begin Popup Box
$left_margin = 0 – ($box_width/2);
$page_url = basename($_SERVER['PHP_SELF']);
if ($extension!="") $page_url .= '?' . $extension;
if (isset($_GET['popup'])) {
echo '<div class="popup" style="width:'.$box_width.'px; background: #'.$box_background.'; margin-left:'.$left_margin.'px;';
if ($box_border_width>1) echo ' border: '.$box_border_width.'px solid #'.$box_border_color.';';
echo '">';
//Close Box
if ($close_box===1) echo '<div class="popup_close"><a href="'.$page_url.'">Close (x)</a></div>';
?>
<!– START YOUR POPUP CONTENT HERE –>
Popup content goes in here!
<!– END OF YOUR POPUP CONTENT HERE –>
<?php
echo '</div>
<div class="fade" onclick="location.replace(\''.$page_url.'\');" style="opacity: 0.'.$fade_amount.'; -moz-opacity: 0.'.$fade_amount.';filter: alpha(opacity: '.$fade_amount.');"></div>
<div class="fade_container">';
}
?>
Looking at the top part of what you just added, the setting are at the top. Just configure it to what ever you like.
The Content
The content of your popup box goes in between the HTML comment tag in the code above. Exactly where I wrote: Popup content goes in here!
Popup content goes in here!
<!– END OF YOUR POPUP CONTENT HERE –>
Next you need the trigger to activate the popup. Something like this:
To finish off the code you will need to add a </div> tag just before the </body> closing tag. Like so:
That's it and all you need to have your own in page with faded background popup window. Wasn't that just simple?
Advance Configuration
Now if your pages require other variables to be passed through the URL I noticed that the popup will intrude on that. So I have an extension variable where you can attach other variables to and they will be kept. The variable is in the setting part of the code. Example of attaching some variables.
$extension = 'p=3&sort=2&id=214423';













Hello !
I liked this post. I tried to implement this..But i am getting an error..
This code in html page or php page
<a href="?popup=1">Activated Box
please reply me..I like this concept want to use..
Thanks in advance..
What is the error that is appearing?