Question to say "I can!"

带关闭功能的漂浮图片代码

2011-06-29

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

~

~

~

~

<div id="xixun" 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://dhdszx.edudh.net/E_ReadNews.asp?NewsId=1756" target="_blank">
<img src="http://dhdszx.edudh.net/images/xixun.jpg" 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('xixun').style.visibility='hidden';
}
</script>



作者:admin | Categories:设计问题 | Tags:

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*

无觅相关文章插件,快速提升流量