JavaScript全屏漂浮广告代码

广告图片全屏漂浮,鼠标放上去停在浮动,鼠标移出后继续浮动,JavaScript代码:

<div id=”floatLayer” style=”position:absolute”>
<a href=”http://www.taojie.com/” target=”_blank”><img src=”广告图片” mce_src=”广告图片” border=”0″></img></a>
</div>
<script language=”JavaScript”>
var x = 50,y = 60; // 起始位置
var xin = false, yin = true;
var step = 1;
var delay = 30;
var obj = document.getElementById(”floatLayer”);
function floatIt()
{
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(”floatIt()”, delay)
obj.onmouseover=function() {clearInterval(itl);}
obj.onmouseout=function(){itl=setInterval(”floatIt()”, delay);}
</script>

Leave a Reply


闽ICP备05021301号