首页 > web前端 > js教程 > 正文

js调用图片隐藏&显示实现代码_javascript技巧

WBOY
发布: 2016-05-16 17:22:43
原创
1261 人浏览过
复制代码 代码如下:





<script> <BR>var intTimeStep=20; <BR>var isIe=(window.ActiveXObject)?true:false; <BR>var intAlphaStep=(isIe)?5:0.05; <BR>var curSObj=null; <BR>var curOpacity=null; <BR>function startObjVisible(objId) <BR>{ <BR>curSObj=document.getElementById(objId); <BR>setObjState(); <BR>} <BR>function setObjState(evTarget) <BR>{ <BR>if (curSObj.style.display==""){curOpacity=1;setObjClose();} <BR>else{ <BR>if(isIe) <BR>{ <BR>curSObj.style.cssText='DISPLAY: none;Z-INDEX: 1; FILTER: alpha(opacity=0); POSITION: absolute;'; <BR>curSObj.filters.alpha.opacity=0; <BR>}else <BR>{ <BR>curSObj.style.opacity=0 <BR>} <BR>curSObj.style.display=''; <BR>curOpacity=0; <BR>setObjOpen(); <BR>} <BR>} <BR>function setObjOpen() <BR>{ <BR>if(isIe) <BR>{ <BR>curSObj.filters.alpha.opacity+=intAlphaStep; <BR>if (curSObj.filters.alpha.opacity<100) setTimeout('setObjOpen()',intTimeStep); <BR>}else{ <BR>curOpacity+=intAlphaStep; <BR>curSObj.style.opacity =curOpacity; <BR>if (curOpacity<1) setTimeout('setObjOpen()',intTimeStep); <BR>} <BR>} <BR>function setObjClose() <BR>{ <BR>if(isIe) <BR>{ <BR>curSObj.filters.alpha.opacity-=intAlphaStep; <BR>if (curSObj.filters.alpha.opacity>0) { <BR>setTimeout('setObjClose()',intTimeStep);} <BR>else {curSObj.style.display="none";} <BR>}else{ <BR>curOpacity-=intAlphaStep; <BR>if (curOpacity>0) { <BR>curSObj.style.opacity =curOpacity; <BR>setTimeout('setObjClose()',intTimeStep);} <BR>else {curSObj.style.display='none';} <BR>} <BR>} <BR></script>








相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板