JavaScript-浮动广告
2013-03-13 14:47
288 查看
<img id="float" style="position:absolute" src="http://img.baidu.com/img/logo-zhidao.gif" /> <script> var xPos = 0, yPos = 0, step = 1, yon = 0, xon = 0; var img = document.getElementById("float"); function changePos() { var width = document.body.clientWidth; var height = document.body.clientHeight; var Hoffset = img.offsetHeight; var Woffset = img.offsetWidth; img.style.left = xPos + document.body.scrollLeft; img.style.top = yPos + document.body.scrollTop; if (yon) { yPos = yPos + step; } else { yPos = yPos - step; } if (yPos < 0) { yon = 1; yPos = 0; } if (yPos >= (height - Hoffset)) { yon = 0; yPos = (height - Hoffset); } if (xon) { xPos = xPos + step; } else { xPos = xPos - step; } if (xPos < 0) { xon = 1; xPos = 0; } if (xPos >= (width - Woffset)) { xon = 0; xPos = (width - Woffset); } setTimeout('changePos()', 30); } window.onload = changePos; </script>
相关文章推荐
- JavaScript - 浮动广告窗口实例
- Javascript应用--浮动的广告图片
- Javascript 广告浮动效果在浏览器中间N秒后移动到右下角
- Javascript浮动广告图片代码,已封装!兼容性强!使用简单!
- javascript广告代码_两侧浮动
- JavaScript制作浮动广告
- [Javascript] 右边贴底浮动广告代码模板
- html+javascript实现广告窗自由浮动
- JavaScript实现网页上的浮动广告的简单方法
- Javascript浮动广告图片代码,已封装!兼容性强!使用简单!
- javascript浮动广告
- JavaScript浮动广告
- 如何利用JAVASCRIPT实现浮动广告
- javascript:广告、文字跑马灯、图片浮动案例
- JavaScript 网页两侧对联浮动广告
- ASP.NET 2.0的Master页中写入javascript浮动对联广告,不能浮动。
- javascript 页面 浮动 广告 代码
- 转摘_用JavaScript实现网页上的浮动广告
- javascript 浮动广告 代码 类
- 自制Javascript浮动广告