漂浮图片上面有个“关闭”,点击可以关闭漂浮图片,用下面的代码就可以实现(可自定义图片):

<div id=”hb400” style=”position:absolute”>
<div style=”width:135;height:18px;font-size:12px;font-weight:bold;text-

align:left;cursor:hand;” onClick=”closead();”><font color=”ff0000″>关闭</font></div>
<a href=”http://www.400hb.com/lt400.html″ target=”_blank”>
<img src=”http://www.400hb.com/Templates/hb400/images/head.gif” border=”0″></a>
</div>
<script>
var x = 307,y = 307
var xin = true, yin = true
var step = 1
var delay = 50
var obj=document.getElementById(“xixun”)
function floatAD() {
var L=T=0
var R= document.body.clientWidth-obj.offsetWidth
var B = document.body.clientHeight-obj.offsetHeight
obj.style.left = x + document.body.scrollLeft
obj.style.top = y + document.body.scrollTop
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(“floatAD()”, delay)
obj.onmouseover=function(){clearInterval(itl)}
obj.onmouseout=function(){itl=setInterval(“floatAD()”, delay)}
function closead()
{
document.getElementById(‘hb400’).style.visibility=’hidden’;
}
</script>

posted on 2012-12-01 10:53  努力实现目标  阅读(6621)  评论(0编辑  收藏  举报