js实现全屏漂浮广告方法二
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Js广告_全屏漂浮广告</title>
<style type="text/css">
div#roll {
width: 100px;
height: 100px;
color: #fff;
background: url(./images/2.jpg) no-repeat;
position: absolute;
}
</style>
</head>
<body>
<div id="roll">我是广告</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>
<script>document.write('<script src="//' + (location.host || 'localhost').split(':')[0] + ':35929/livereload.js?snipver=1"></' + 'script>')</script><script>document.addEventListener('LiveReloadDisconnect', function() { setTimeout(function() { window.location.reload(); }, 500); })</script></body>
</html>
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17634812.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现