javascript 页面 浮动 广告 代码

 <div id="ad" style="position: absolute">
<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=442518843&site=qq&menu=yes">
<img border="0" src="http://wpa.qq.com/pa?p=2:442518843:50" alt="点击我!来聊天!" title="点击我!来聊天!"></a>
</div>
<script type="text/javascript">
var x = 50, y = 60
var xin = true, yin = true
var step = 1
var delay = 100
var obj = document.getElementById("ad")
function float() {
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("float()", delay)
obj.onmouseover = function () { clearInterval(itl) }
obj.onmouseout = function () { itl = setInterval("float()", delay) }
</script>

 

你可能感兴趣的:(JavaScript)