var SysIsIE;
var ua = navigator.userAgent.toLowerCase();
var s;(s = ua.match(/msie ([\d.]+)/)) ? SysIsIE = s[1] : 0;
function Q(s){
return document.getElementById(s);
}
function dvck(){
idstr='tian';
e=Q(idstr);
if(e){
e.parentNode.removeChild(e);
}
var div=document.createElement("div");
div.style.position="absolute";
div.style.top='10%';
div.style.left='40%';
div.style.cssText='filter: alpha(opacity=10);opacity:0.1;position:absolute;top:50%;left:50%;width:544px;height:354px;margin-top:-177px;margin-left:-272px;;background-color:#000';
div.id=idstr;
//div.innerHTML='';
div.innerHTML='
';document.body.appendChild(div);
if (SysIsIE)
dcbIE(idstr,'+');
else
dcboth(idstr,'+');
}
function dcbIE(s,j){
o=Q(s);
opc=parseInt(o.filters.alpha.opacity);
if(j=='+'){
if(opc<100){
o.filters.alpha.opacity=(opc+10)+'';
setTimeout("dcbIE('"+s+"','"+j+"')",100);
}
}else if(j=='-'){
if(opc>0){
o.filters.alpha.opacity=(opc-10)+'';
setTimeout("cleand('"+s+"','"+j+"')",100);
}
}
}
function dcboth(s,j){
o=Q(s);
opc=parseFloat(o.style.opacity);
if(j=='+'){
if(opc<1){
o.style.opacity=(opc+0.1)+'';
//setInterval("dcboth('"+s+"')",3000);
setTimeout("dcboth('"+s+"','"+j+"')",100);
}
}else if(j=='-'){
if(opc>0){
o.style.opacity=(opc-0.1)+'';
setTimeout("cleand('"+s+"','"+j+"')",100);
}
}
}
function cleand(s){
if (SysIsIE){
dcbIE(s,'-');
}else{
dcboth(s,'-');
}
}
javascript控制Div层透明属性,由浅变深逐渐显示,由深变浅逐渐消失.
单击'click'显示层,由浅变深逐渐显示
click
在显示的层上单击,可以由深变浅逐渐消失
jquery中文网,欢迎大家的光临。