随笔 - 285,  文章 - 0,  评论 - 142,  阅读 - 260万

点击这里查看效果

以下是代码:

复制代码
 1 <!DOCTYPE HTML>
 2 <html>
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>JS全屏漂浮广告-柯乐义</title>
 6 <style type="text/css">
 7 div#roll{width:100px;height:100px; background-color:#000; color:#fff; position:absolute;}
 8 </style>
 9 </head>
10 
11 <body>
12 <div>
13 <div><h2>JS全屏漂浮广告,移入光标停止移动·柯乐义</h2><a href="http://keleyi.com/a/bjac/ara6jk5h.htm" target="_blank">原文</a></div>
14 </div>
15 <div id="roll">我是广告<br />keleyi.com</div>
16 <script type="text/javascript">
17 var ggRoll = {
18 roll: document.getElementById("roll"),
19 speed: 20,
20 statusX: 1,
21 statusY: 1,
22 x: 100,
23 y: 300,
24 winW: document.documentElement.clientWidth - document.getElementById("roll").offsetWidth,
25 winH: document.documentElement.clientHeight - document.getElementById("roll").offsetHeight,
26 Go: function () {
27 this.roll.style.left = this.x + 'px';
28 this.roll.style.top = this.y + 'px';
29 
30 this.x = this.x + (this.statusX ? -1 : 1)
31 if (this.x < 0) { this.statusX = 0 }
32 if (this.x > this.winW) { this.statusX = 1 }
33 
34 this.y = this.y + (this.statusY ? -1 : 1)
35 if (this.y < 0) { this.statusY = 0 }
36 if (this.y > this.winH) { this.statusY = 1 }
37 }
38 }
39 var interval = setInterval("ggRoll.Go()", ggRoll.speed);
40 ggRoll.roll.onmouseover = function () { clearInterval(interval) };
41 ggRoll.roll.onmouseout = function () { interval = setInterval("ggRoll.Go()", ggRoll.speed) };
42 
43 </script>
44 </body>
45 </html>
复制代码

转载自:http://keleyi.com/a/bjac/ara6jk5h.htm

http://www.cnblogs.com/jihua/p/webfront.html

posted on   计划  阅读(3954)  评论(2编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示