div 在页面上漂浮

<div id="codefans_net" style="position:absolute;z-index:5;">
        <a><img src="/template/[field:css_color]/images/float.jpg" border="0"></a><--漂浮图片-->
        <br/>
        <a target="_blank" style="cursor:pointer; position:absolute; right:10px; bottom:0px;" onclick="javascript:turnoff('codefans_net')"><font color="#FFFFFF">点击关闭<font/></a>
    </div>
    <script>
 function turnoff(obj){
  document.getElementById(obj).style.display="none";
 }
 </script>
 <script>
 var x = 50,y = 60
 var xin = true, yin = true
 var step = 1
 var delay = 10
 var obj=document.getElementById("codefans_net")
 function floatpiao() {
 var L=T=0
 var R= document.documentElement.clientWidth-obj.offsetWidth
 var B = document.documentElement.clientHeight-obj.offsetHeight
 obj.style.left = x + document.documentElement.scrollLeft + 'px';
 obj.style.top = y + document.documentElement.scrollTop + 'px';
 x = x + step*(xin?1:-1)
 if (x < L) { xin = true; x = L}
 if (x > R){ xin = false; x = R}
 y = y + step*(yin?1:-1)
 if (y < T) { yin = true; y = T }
 if (y > B) { yin = false; y = B }
 }
 var itl= setInterval("floatpiao()", delay)
 obj.onmouseover=function(){clearInterval(itl)}
 obj.onmouseout=function(){itl=setInterval("floatpiao()", delay)}
 </script>

上一篇:深度分析Java的枚举类型—-枚举的线程安全性及序列化问题


下一篇:深度分析Java的ClassLoader机制(源码级别)