2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > js实现全屏漂浮广告方法三

js实现全屏漂浮广告方法三

时间:2024-02-27 18:21:29

相关推荐

js实现全屏漂浮广告方法三

<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"><title>简单JS动画实例 广告移动效果</title></head><body><div id="one" style="background:url(images/1.jpg) no-repeat; position:absolute; left:0; top:0; height:100px; height:100px; ">移动广告</div><script type="text/javascript">var x = 0; //对象X轴位置var y = 0; //对象Y轴位置var xs = 10; //对象X轴移动速度var ys = 10; //对象Y轴移动速度var one = document.getElementById('one');function move() {x += xs;y += ys;one.style.left = x;one.style.top = y;if (x > document.body.clientWidth - one.offsetWidth - 20 || x < 0) {xs = -1 * xs; //速度取反}if (y > document.body.clientHeight - one.offsetHeight - 20 || y < 0) {ys = -1 * ys;}}var obj = setInterval('move()', 100);one.onmouseover = function() { //clearInterval(obj);}one.onmouseout = function() {obj = setInterval('move()', 100);}</script></body></html>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。