Shell

推荐列表 站点导航

当前位置:首页 > 脚本编程 > Shell >

js全屏漂浮广告代码 移入光标停止移动

来源:网络整理  作者:网友投稿  发布时间:2020-12-28 23:34
本文介绍了js全屏漂浮广告的实现代码,当移入光标时停止移动效果,不错的js漂浮广告代码,有需要的朋友参考下。...

例子,js实现漂浮广告效果的代码。
 

复制代码 代码示例:

<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>js全屏漂浮广告_jquerycn.cn</title>
<style type="text/css">
div#roll{width:100px;height:100px; background-color:#000; color:#fff; position:absolute;}
</style>
</head>
<body>
<div>
<div><h2>js全屏漂浮广告,移入光标停止移动</h2></div>
</div>
<div id="roll">我是广告<br /></div>
<script type="text/javascript">
var ggroll = {
roll: document.getelementbyid("roll"),
speed: 20,
statusx: 1,
statusy: 1,
x: 100,
y: 300,
winw: document.documentelement.clientwidth - document.getelementbyid("roll").offsetwidth,
winh: document.documentelement.clientheight - document.getelementbyid("roll").offsetheight,
go: function () {
this.roll.style.left = this.x + 'px';
this.roll.style.top = this.y + 'px';
this.x = this.x + (this.statusx ? -1 : 1)
if (this.x < 0) { this.statusx = 0 }
if (this.x > this.winw) { this.statusx = 1 }
this.y = this.y + (this.statusy ? -1 : 1)
if (this.y < 0) { this.statusy = 0 }
if (this.y > this.winh) { this.statusy = 1 }
}
}
var interval = setinterval("ggroll.go()", ggroll.speed);
ggroll.roll.onmouseover = function () { clearinterval(interval) };
ggroll.roll.onmouseout = function () { interval = setinterval("ggroll.go()", ggroll.speed) };
</script>
</body>
</html>

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://www.juheyunku.com/jiaob/shell/10429.shtml

相关文章
最新文章
Centos下PHP5升级为PHP7的方法 Centos下PHP5升级为PHP7的方法

时间:2021-01-03

在php当中常量和变量的区 在php当中常量和变量的区

时间:2020-12-29

PHP中经典的四大排序算法 PHP中经典的四大排序算法

时间:2020-12-29

dw怎么运行php文件? dw怎么运行php文件?

时间:2020-12-29

PHP PHP_EOL 换行符 PHP PHP_EOL 换行符

时间:2020-12-29

Python3爬虫进阶:MongoDB存储 Python3爬虫进阶:MongoDB存储

时间:2020-12-29

python如何运行一个python程 python如何运行一个python程

时间:2020-12-29

用PHP写一个计算器(附完 用PHP写一个计算器(附完

时间:2020-12-29

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

js全屏漂浮广告代码 移入光标停止移动

2020-12-28 编辑:网友投稿

例子,js实现漂浮广告效果的代码。
 

复制代码 代码示例:

<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>js全屏漂浮广告_jquerycn.cn</title>
<style type="text/css">
div#roll{width:100px;height:100px; background-color:#000; color:#fff; position:absolute;}
</style>
</head>
<body>
<div>
<div><h2>js全屏漂浮广告,移入光标停止移动</h2></div>
</div>
<div id="roll">我是广告<br /></div>
<script type="text/javascript">
var ggroll = {
roll: document.getelementbyid("roll"),
speed: 20,
statusx: 1,
statusy: 1,
x: 100,
y: 300,
winw: document.documentelement.clientwidth - document.getelementbyid("roll").offsetwidth,
winh: document.documentelement.clientheight - document.getelementbyid("roll").offsetheight,
go: function () {
this.roll.style.left = this.x + 'px';
this.roll.style.top = this.y + 'px';
this.x = this.x + (this.statusx ? -1 : 1)
if (this.x < 0) { this.statusx = 0 }
if (this.x > this.winw) { this.statusx = 1 }
this.y = this.y + (this.statusy ? -1 : 1)
if (this.y < 0) { this.statusy = 0 }
if (this.y > this.winh) { this.statusy = 1 }
}
}
var interval = setinterval("ggroll.go()", ggroll.speed);
ggroll.roll.onmouseover = function () { clearinterval(interval) };
ggroll.roll.onmouseout = function () { interval = setinterval("ggroll.go()", ggroll.speed) };
</script>
</body>
</html>

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://www.juheyunku.com/jiaob/shell/10429.shtml

相关文章

风云图片

推荐阅读

返回Shell频道首页