>
设为首页
>
收藏本站
>
最新电影
首页
运营资讯
今日英语
图形图像
计算机技术
Asp编程
网站结构化
资源共享
休闲娱乐
访问新站
您现在的位置:
首页
=>
后台技术
=>
脚本特效
=>
其他
订阅本栏目
无缝滚动 支持xhtml标准
时间: 2008-04-14 17:52:42 阅读次数:2661
无缝滚动 支持xhtml标准
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>完美无缝滚动</title> </head> <body> <div id="demo" style="width:65px;height:30px;"> <img src="/images/logo.png" width="65" height="65" /> </div> <div id="demo2" style="width:65px;height:30px;"> <img src="/images/logo.png" width="65" height="65" /> </div> <div id="demo1" style="width:30px;"> <img src="/images/logo.png" width="65" height="65" /> </div> <div id="demo3" style="width:30px;"> <img src="/images/logo.png" width="65" height="65" /> </div> <script type="text/javascript"> <!-- String.prototype.format = function(){ var tmpStr = this; var iLen = arguments.length; for(var i=0;i<iLen;i++){ tmpStr = tmpStr.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]); } return tmpStr; } function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; } function IMarquee(){ function throwError(){alert("接口未实现:" + arguments[0]);} this.Scroll = function(){throwError("Scroll");} this.Clone = function(){throwError("Clone");} } function AbstractMarquee(){ IMarquee.apply(this); var ref = this; var timer = null; var container = null; var indexs = ["ContainerID", "Delay", "Amount", "Width", "Height"]; this.Amount = 1; this.Delay = 30; this.Width = 0; this.Height = 0; this.ContainerID = ""; this.Start = function(){ clearTimer(); timer = setInterval(ref.Scroll, ref.Delay); } this.Stop = function(){ clearTimer(); } this.Pause = function(){ clearTimer(); } this.Init = function(){ container = $(this.ContainerID); if(container == null) {alert("无法找到id为{0}的对象,初始化失败。".format(this.ContainerID));return;}; container.style.overflow = "hidden"; if(this.Width > 0) container.style.width = this.Width + "px"; if(this.Height > 0) container.style.height = this.Height + "px"; this.Clone(); this.AttachEvent(); this.Start(); } this.AttachEvent = function(){ container.onmouseover = ref.Pause; container.onmouseout = ref.Start; } function clearTimer(){ if(timer != null)clearInterval(timer); } function _Marquee(){ var max = Math.min(indexs.length, arguments.length); for(var i=0;i<max;i++) this[indexs[i]] = arguments[i]; } _Marquee.apply(this, arguments); } function MarqueeUp(){ AbstractMarquee.apply(this, arguments); var ref = this; var container = $(this.ContainerID); this.Clone = function(){ container.innerHTML = '<div>{0}</div><div>{0}</div>'.format(container.innerHTML); } this.Scroll = function(){ with(container){ if(scrollTop >= lastChild.offsetTop) scrollTop -= firstChild.offsetHeight; else scrollTop += ref.Amount; } } } function MarqueeDown(){ AbstractMarquee.apply(this, arguments); var ref = this; var container = $(this.ContainerID); this.Clone = function(){ container.innerHTML = '<div>{0}</div><div>{0}</div>'.format(container.innerHTML); container.scrollTop = container.scrollHeight; } this.Scroll = function(){ with(container){ if(scrollTop <= firstChild.offsetTop) scrollTop += lastChild.offsetHeight; else scrollTop -= ref.Amount; } } } function MarqueeLeft(){ AbstractMarquee.apply(this, arguments); var ref = this; var container = $(this.ContainerID); this.Clone = function(){ container.innerHTML = '<table cellspacing="0" cellpadding="0" border="0"><tr><td>{0}</td><td>{0}</td></tr></table>'.format(container.innerHTML); } this.Scroll = function(){ with(container){ if(scrollLeft >= firstChild.rows[0].cells[1].offsetLeft) scrollLeft -= firstChild.rows[0].cells[0].offsetWidth; else scrollLeft += ref.Amount; } } } function MarqueeRight(){ AbstractMarquee.apply(this, arguments); var ref = this; var container = $(this.ContainerID); this.Clone = function(){ container.innerHTML = '<table cellspacing="0" cellpadding="0" border="0"><tr><td>{0}</td><td>{0}</td></tr></table>'.format(container.innerHTML); container.scrollLeft = container.scrollWidth; } this.Scroll = function(){ with(container){ if(scrollLeft <= firstChild.rows[0].cells[0].offsetLeft) scrollLeft += firstChild.rows[0].cells[1].offsetWidth; else scrollLeft -= ref.Amount; } } } var Marquee = { Type : { UP : function(){return new MarqueeUp(arguments[0]);}, DOWN : function(){return new MarqueeDown(arguments[0]);}, LEFT : function(){return new MarqueeLeft(arguments[0]);}, RIGHT : function(){return new MarqueeRight(arguments[0]);} }, newInstance : function(type, container){ return this.Type[type.toUpperCase()].call(this, container); } } var marquee = Marquee.newInstance("Up", "demo"); marquee.Init(); var m1 = Marquee.newInstance("Left", "demo1"); m1.Init(); var m2 = Marquee.newInstance("Down", "demo2"); m2.Init(); var m3 = Marquee.newInstance("Right", "demo3"); m3.Init(); //--> </script> </body> </html>
提示:您可以先修改部分代码再运行
站内搜索
:
标题
内容
下一篇
飞飞input表单输入框默认提示信息插件
上一篇
用键盘打开网页代码
本栏目最新
栏目最新列表
xhEditor v1.1.7 发布,国产开源XHTML在线编
收集的一些轻量级非常实用的前端开发小工具
javascript中cookie的设置,读取,删除
jquery插件:飞飞表情插件v1.0_[普通表情/魔
Jquery插件:textarea使用“autoresize”自
网站优化策划
栏目最新列表
增加网站外链的快速方法
网站上线前必做的30个检查
新的友情链接参考标准(没有google的PR情况
优化Google的AdSense广告的五个工具
王通讲SEO八大基础
站点最新
站点最新列表
微博推广的一些技巧
xhEditor v1.1.7 发布,
收集的一些轻量级非常实
50个新鲜兼容最新版本的
javascript中cookie的设
Excel中出现#VALUE!、#D
jquery插件:飞飞表情插件
十个使用HTML5开发的精彩
支持HTML5的浏览器有哪些
飞妮莫属:漫画:如何写出
历史最热10条信息
MIME介绍 及
[
1
] [
2
] [
3
]
巧用Google和迅雷来下载
Transact SQL 常
[
1
] [
2
]
VIA Rhine II Fast Ethe
电脑常用端
[
1
] [
2
] [
3
]
Do you get a kick out
十道羊皮卷 欣赏+mp3版+
每日一句:A friend and
每日一句:Theres no tu
经典__悟透JavaScript
伟哥博客
西安房产
123最新电影
三四六四
关于站点
|
免责声明
|
联系站长
|
网站地图
|
陕ICP备07002804号
WEB技术QQ交流群:72840059
©2007 ffasp.com. 版权所有