코드 붙 이기
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> _www.jb51.net</title>
<link type="text/css" rel="stylesheet" href="window.css">
<script language="javascript" type="text/javascript" src="../../jquery/jquery.js"></script>
<script language="javascript" type="text/javascript" src="window.js"></script>
<script language="javascript">
$(document).ready(function (){
$("#btn_center").click(function (){
$(window).scroll(function (){
popcenterWindow();
});
});
$("#btn_right").click(function (){
$(window).scroll(function (){
poprightWindow();
});
});
$("#btn_left").click(function (){
$(window).scroll(function (){
popleftWindow();
});
});
});
</script>
</head>
<body>
<input type="button" value=" " id="btn_center">
<input type="button" value=" " id="btn_right">
<input type="button" value=" " id="btn_left">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<div class="window" id="center">
<div class="title"><img src="close.gif">csdn </div>
<div class="content"> </div>
</div>
<div class="window" id="right">
<div class="title"><img src="close.gif">csdn </div>
<div class="content"> </div>
</div>
<div class="window" id="left">
<div class="title"><img src="close.gif">csdn </div>
<div class="content"> </div>
</div>
</body>
</html>
JS
//
var windowHeight;
//
var windowWidth;
//
var popHeight;
//
var popWidth;
//
var scrollTop;
//
var scrollleft;
//
var timeout;
function init(){
//
windowHeight=$(window).height();
//
windowWidth=$(window).width();
//
popHeight=$(".window").height();
//
popWidht=$(".window").width();
//
scrollTop=$(window).scrollTop();
//
scrollleft=$(window).scrollLeft();
}
//
function closeWindow(){
$(".title img").click(function (){
$(this).parent().parent().hide("slow");
});
}
//
function popcenterWindow(){
//
clearTimeout(timeout);
timeout=setTimeout(function (){
init();
var popY=(windowHeight-popHeight)/2+scrollTop;
var popX=(windowWidth-popWidht)/2+scrollleft;
$("#center").animate({top:popY,left:popX},300).show("slow");},300);
closeWindow();
}
function popleftWindow(){
clearTimeout(timeout);
timeout=setTimeout(function (){
init();
var popY=windowHeight+scrollTop-popHeight-10;
var popX=scrollleft-5;
$("#left").animate({top:popY,left:popX},300).show("slow");},300);
closeWindow();
}
function poprightWindow(){
clearTimeout(timeout);
timeout=setTimeout(function (){
init();
var popY=windowHeight-popHeight+scrollTop-10;
var popX=windowWidth-popWidht+scrollleft-10;
$("#right").animate({top:popY,left:popX},300).show("slow");},300);
closeWindow();
}
CSS
<SPAN style="FONT-SIZE: 18px">.window{
width:250px;
background-color:#3FF;
padding:2px;
margin:5px;
position:absolute;
display:none;
}
.content{
height:150px;
background-color:#FFF;
padding:2px;
font-size:14px;
overflow:auto;
}
.title{
padding:2px;
color:#999;
font-size:14px;
}
.title img{
float:right;
cursor:pointer;
}</SPAN>