国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

javascript控制Div層透明屬性由淺變深由深變淺逐漸顯示

2019-11-20 21:43:28
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
搬運(yùn)的留著以后自己看!

復(fù)制下面藍(lán)色的代碼保存為html格式的文件,使用網(wǎng)頁(yè)瀏覽器瀏覽效果

代碼支持IE6、7、8/firefox/Chrome瀏覽器
復(fù)制代碼 代碼如下:

<!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=gb2312" />
<title>javascript控制Div層透明屬性,由淺變深逐漸顯示,由深變淺逐漸消失</title>
<script>
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='<img src="i.jpg" onclick="cleand(/''+idstr+'/')" />';
div.innerHTML='<p style="color:#fff;text-align:center;">div層顯示的內(nèi)容,author:<a style="color:#FBFC4D">bluid</a><br><br><br><br><br><a href="javascript:cleand(/''+idstr+'/')" style="color:#FEF8C3">關(guān)閉</a></p>';
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,'-');
}
}
</script>
</head>
<body>
<div><br><br>
<p style="font-size:14px">javascript控制Div層透明屬性,由淺變深逐漸顯示,由深變淺逐漸消失.</p><br><br>
<br><br><br>
<p>單擊'click'顯示層,由淺變深逐漸顯示</p><br><br><br><br>
<a href="javascript:dvck()">click</a><br><br><br><br>
<p>在顯示的層上單擊,可以由深變淺逐漸消失</p>
<br><br><br>
<p>
<!-- #BeginDate format:Am3m -->02/11/2011 16:17<!-- #EndDate --> --- author:<a >bluid</a>
</p>
<br><br><br><br>
<br><br>
</div>
</body>
</html>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 鄂托克旗| 南川市| 根河市| 永丰县| 茂名市| 赤城县| 蓬安县| 泰来县| 手游| 延川县| 双辽市| 中方县| 屏东县| 札达县| 长寿区| 阜康市| 土默特右旗| 定襄县| 昌吉市| 南华县| 汤阴县| 阿拉善盟| 拜城县| 京山县| 东山县| 朝阳县| 宁远县| 鸡泽县| 寿阳县| 绿春县| 宽甸| 博野县| 若羌县| 息烽县| 台北县| 惠来县| 塘沽区| 靖安县| 札达县| 凯里市| 普定县|