你的位置:首页 > Java教程

[Java教程]JavaScript动画打开半透明提示层


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DOM半透明提示层</title>
<style type="text/css">
body,span,div,td{font-size:12px;line-height:1.5em;color:#849BCA;}
#bodyL{
float:left;
width:84px;
margin-right:2px;
}
a.od{
width:80px;
height:25px;
line-height:25px;
text-align:center;
font-weight:bold;
border: 2px solid #849BCA;
display:block;
color:#547BC9;
float:left;
text-decoration:none;
margin-top:2px;
}
a.od:link{
background:#EEF1F8;
}
a.od:visited{
background:#EEF1F8;
}
a.od:hover{
background:#EEE;
}
a.od:active{
background:#EEE;
}
#fd{
width:500px;
height:200px;
background:#EDF1F8;
border: 2px solid #849BCA;
margin-top:2px;
margin-left:2px;
float:left;
overflow:hidden;
position:absolute;
left:0px;
top:0px;
cursor:move;
float:left;
}
.content{
padding:10px;
}
</style>
</head>
<body>
<div id="bodyL">
<a href="#" onclick = "show('fd');return false;">
[打开层]
</a>
<a href="#" onclick = "closeed('fd');return false;">
[关闭层]
</a>
</div>
<div id="fd" >
<div >移动层</div>
</div>
<script type="text/javascript">
var prox;
var proy;
var proxc;
var proyc;
function show(id){/*--打开--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
o.style.display = "block";
o.style.width = "1px";
o.style.height = "1px";
prox = setInterval(function(){openx(o,500)},10);
}
function openx(o,x){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx < x)
{
o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
}
else
{
clearInterval(prox);
proy = setInterval(function(){openy(o,200)},10);
}
}
function openy(o,y){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy < y)
{
o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
}
else
{
clearInterval(proy);
}
}
function closeed(id){/*--关闭--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if(o.style.display == "block")
{
proyc = setInterval(function(){closey(o)},10);
}
}
function closey(o){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy > 0)
{
o.style.height = (cy - Math.ceil(cy/5)) +"px";
}
else
{
clearInterval(proyc);
proxc = setInterval(function(){closex(o)},10);
}
}
function closex(o){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx > 0)
{
o.style.width = (cx - Math.ceil(cx/5)) +"px";
}
else
{
clearInterval(proxc);
o.style.display = "none";
}
}
/*鼠标拖动*/
var od = document.getElementById("fd");
var dx,dy,mx,my,mouseD;
var odrag;
var isIE = document.all ? true : false;
document.onmousedown = function(e){
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mouseD = true;
}
}
document.onmouseup = function(){
mouseD = false;
odrag = "";
if(isIE)
{
od.releaseCapture();
od.filters.alpha.opacity = 100;
}
else
{
window.releaseEvents(od.MOUSEMOVE);
od.style.opacity = 1;
}
}
//function readyMove(e){
od.onmousedown = function(e){
odrag = this;
var e = e ? e : event;
if(e.button == (document.all ? 1 : 0))
{
mx = e.clientX;
my = e.clientY;
od.style.left = od.offsetLeft + "px";
od.style.top = od.offsetTop + "px";
if(isIE)
{
od.setCapture();
od.filters.alpha.opacity = 50;
}
else
{
window.captureEvents(Event.MOUSEMOVE);
od.style.opacity = 0.5;
}
//alert(mx);
//alert(my);
}
}
document.onmousemove = function(e){
var e = e ? e : event;
//alert(mrx);
//alert(e.button);
if(mouseD==true && odrag)
{
var mrx = e.clientX - mx;
var mry = e.clientY - my;
od.style.left = parseInt(od.style.left) +mrx + "px";
od.style.top = parseInt(od.style.top) + mry + "px";
mx = e.clientX;
my = e.clientY;
}
}
</script><br/>
<div>http://www.999jiujiu.com/</div>
</body>
</html>




跟团去重庆旅游多少钱几月去重庆旅游最好去重庆的旅游团价格去重庆旅游必去景点去重庆旅游要多少钱河南开封府门票价格多少钱 塔尔寺门票_塔尔寺门票价格_塔尔寺门票价格是多少 承德避暑山庄门票_避暑山庄门票价格_避暑山庄门票多少钱 神农架在哪里_湖北十堰神农架在哪_神农架在哪个省 西安世园会蝶恋花舞台迎来首演 运城民间社火 西安世园会游客量大幅上升 百年天津大变身_感受空中银河的前世今生 浮盖山峡谷漂流附近景点有哪些?江山浮盖山峡谷漂流周边景区? 浮盖山峡谷漂流小孩多少钱?江山浮盖山峡谷漂流儿童票价格? 富华游乐园演出时间表?潍坊富华游乐园演出节目介绍? 浮盖山峡谷漂流小孩能漂吗?江山浮盖山峡谷漂流适合多大的儿童玩? 马提尼克 让人长高的南美神奇小岛(全文) 三亚槟榔谷有直达车吗?三亚到槟榔谷怎么坐车? 2015-2015广州跨年演唱会在哪里?2015元旦广州明星演唱会门票预订? 2015-2015深圳跨年演唱会哪里有?2015元旦深圳演唱会门票预订? TK12X60U(TE24L,Q) Datasheet TK12X60U(TE24L,Q) Datasheet TK12J60U(F) Datasheet TK12J60U(F) Datasheet STI18NM60N Datasheet STI18NM60N Datasheet 龙凤山庄好玩吗 龙凤山庄好玩吗 龙凤山庄好玩吗 香港尖沙咀海港城 香港尖沙咀海港城 香港尖沙咀海港城 连州地下河好玩吗 连州地下河好玩吗 连州地下河好玩吗