弹出一个淡入淡出的提示框,且自动消失

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>点击按钮弹出一个淡入淡出的提示框,且自动消失丨芯晴网页特效丨CsrCode.Cn</title>
    <SCRIPT>
    var intTimeStep=20;
    var isIe=(window.ActiveXObject)?true:false;
    var intAlphaStep=(isIe)?5:0.05;
    var curSObj=null;
    var curOpacity=null;
    var stopTime=0;
    function startObjMessage(objId)
    {
    curSObj=document.getElementById(objId);
    if(isIe){curSObj.style.cssText='DISPLAY: none; Z-INDEX: 1; FILTER: alpha(opacity=0); POSITION: absolute;';}
    setMessage();
    }
    function setMessage()
    {
    if(isIe){curSObj.filters.alpha.opacity=0;}
    else{curOpacity=0;curSObj.style.opacity=0}
    curSObj.style.display='';
    setMessageShow();
    }
    function setMessageShow()
    {
    if(isIe)
    {
    curSObj.filters.alpha.opacity+=intAlphaStep;
    if (curSObj.filters.alpha.opacity<100) {setTimeout('setMessageShow()',intTimeStep);}
    else{stopTime+=10;if(stopTime<500){setTimeout('setMessageShow()',intTimeStep);}else{stopTime=0;setMessageClose();}}
    }else
    {
    curOpacity+=intAlphaStep;
    curSObj.style.opacity =curOpacity;
    if (curOpacity<1) {setTimeout('setMessageShow()',intTimeStep);}
    else{stopTime+=10;if(stopTime<200){setTimeout('setMessageShow()',intTimeStep);}else{stopTime=0;setMessageClose();}}
    }
    }
    function setMessageClose()
    {
    if(isIe)
    {
    curSObj.filters.alpha.opacity-=intAlphaStep;
    if (curSObj.filters.alpha.opacity>0) {
    setTimeout('setMessageClose()',intTimeStep);
    }
    else {
    curSObj.style.display='none';
    }
    }
    else
    {
    curOpacity-=intAlphaStep;
    if (curOpacity>0) {
    curSObj.style.opacity =curOpacity;
    setTimeout('setMessageClose()',intTimeStep);
    }
    else {
    curSObj.style.display='none';
    }
    }
    }
    </SCRIPT>
    </head>
    <body>
    <table width=80% ID="Table1"><tr><td>预览效果:淡入淡出的弹出消息<br><input type=button onclick="startObjMessage('objDiv')" value="点击弹出消息" ID="Button1" NAME="Button1"></td>
    </tr>
    <tr><td><DIV id="objDiv" style="DISPLAY: none; Z-INDEX: 1; POSITION: absolute; ">
    <img src="/html/txdm_2/images/20100922/1_122131.gif">测试效果<img src="/html/txdm_2/images/20100922/1_122131.gif"></DIV></td></tr>
    </table>
    </body>
    </html>
    <p align="center">本特效由 <a href="http://www.CsrCode.cn" target="_blank">芯晴网页特效</a>丨CsrCode.Cn 收集于互联网,只为兴趣与学习交流,不作商业用途。</p>
    

原文地址:https://www.cnblogs.com/xianyadan/p/6523049.html