PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
|
积分获取
|
给我留言
|
tag标签
首页
开发编程
PHP教程
ASP.NET教程
Jquery教程
Unity3D教程
JavaScript教程
HTML+CSS
ThinkPhp教程
Smarty教程
正则表达式
编程杂谈
HTML5+CSS3教程
HBuilderX教程
AngularJS教程
Laravel教程
iOS开发教程
Java教程
小程序开发
提供网页设计教程和后台编程技术
CMS教程
phpcms教程
dedecms教程
wordpress教程
ecshop教程
帝国cms教程
discuz教程
齐博cms教程
ShopNc教程
提供主流cms教程
数据库
MySQL教程
SQL Server教程
NoSql数据库
提供数据库教程和设计
JS特效
HTML5+CSS3特效
焦点图
菜单导航
广告特效
对联广告
在线客服
相册特效
图片特效
悬浮漂浮
滚动特效
Tab选项卡
瀑布流
手机js特效
弹出层(框)
日期时间
网页模板
其它特效
提供各种常见网页js代码
网页特效
HTML5+CSS3
鼠标特效
文字特效
导航菜单
表格图层
Tab选项卡
图片特效
时间日期
网站常用
提供常用的JS特效代码及在线演示
Jquery插件
jQuery日期时间
jQuery弹出层
jQuery筛选排序
jQuery滚动插件
jQuery工具提示
jQuery音频视频
jQuery选项卡
jQuery图片裁剪
jQuery常用插件
jQuery导航菜单
提供jQuery插件教程及插件下载
服务器
Linux教程
Web服务器
提供服务器常见问题及教程
站长学院
seo技巧
建站经验
网络营销
站长资讯
好文分享
网络推广
互联网资讯
提供站长技术、站长资讯等内容
工具&手册
Base64编码加密
正则测试工具
Css压缩/格式化
jQuery手册
md5加密
CSS3
帝国cms开发手册
DEDE5.7使用手册
配色词典
C语言库
提供常用开发手册和开发工具
全站搜索
搜索
关键字:
备份技术
CSS
经过
对联广告代码
菜单导航
图片放大
折叠
防止
您现在的位置:
首页
>
网页特效
>
文字特效
> 正文
javascript滚动公告板效果
作者:admin
来源:网络
浏览:
次
时间:2020-10-24 21:11:49
我要评论
分享到
内容介绍
一个简单的javascript滚动公告板效果代码,希望对你们有啥帮助。
<!DOCTYPE HTML> <html> <head> <title>javascript滚动公告板效果</title> <meta charset=utf-8> </head> <body> <div class="demo-container"> <!--************************************* 实例代码开始 *************************************--> <style type="text/css"> /*Example CSS for the two demo scrollers*/ #pscroller1{ width: 200px; height: 100px; border: 1px solid black; padding: 5px; background-color: lightyellow; } #pscroller2{ width: 450px; height: 20px; border: 1px solid black; padding: 3px; } #pscroller2 a{ text-decoration: none; } .someclass{ //class to apply to your scroller(s) if desired } </style> <script type="text/javascript"> /*Example message arrays for the two demo scrollers*/ var pausecontent=new Array() pausecontent[0]='<a href="http://www.hzhuti.com">艺图</a><br />欣赏高质量的国外艺术大师作品图片。欣赏经典名作,体味艺术人生。' pausecontent[1]='<a href="http://www.111cn.net">111cn.net</a><br />收录经典小段代码,翻译转载国外优秀技术文章。' var pausecontent2=new Array() pausecontent2[0]='<a href="http://www.hzhuti.com">【艺图】 欣赏高质量的国外艺术大师作品图片。欣赏经典名作,体味艺术人生。</a>' pausecontent2[1]='<a href="http://www.111cn.net">【111cn.net】 收录经典小段代码,翻译转载国外优秀技术文章。</a> ' </script> <script type="text/javascript"> /*********************************************** * Pausing up-down scroller- ? Dynamic Drive (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit http://www.dynamicdrive.com/ for this script and 100s more. ***********************************************/ function pausescroller(content, divId, divClass, delay){ this.content=content //message array content this.tickerid=divId //ID of ticker div to display information this.delay=delay //Delay between msg change, in miliseconds. this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is) this.hiddendivpointer=1 //index of message array for hidden div document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>') var scrollerinstance=this if (window.addEventListener) //run onload in DOM2 browsers window.addEventListener("load", function(){scrollerinstance.initialize()}, false) else if (window.attachEvent) //run onload in IE5.5+ window.attachEvent("onload", function(){scrollerinstance.initialize()}) else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec setTimeout(function(){scrollerinstance.initialize()}, 500) } // ------------------------------------------------------------------- // initialize()- Initialize scroller method. // -Get div objects, set initial positions, start up down animation // ------------------------------------------------------------------- pausescroller.prototype.initialize=function(){ this.tickerdiv=document.getElementById(this.tickerid) this.visiblediv=document.getElementById(this.tickerid+"1") this.hiddendiv=this.hiddendiv=document.getElementById(this.tickerid+"2") this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv)) //set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2) this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px" this.getinline(this.visiblediv, this.hiddendiv) this.hiddendiv.style.visibility="visible" var scrollerinstance=this this.tickerdiv.onmouseover=function(){scrollerinstance.mouseoverBol=1} this.tickerdiv.onmouseout=function(){scrollerinstance.mouseoverBol=0} setTimeout(function(){scrollerinstance.animateup()}, this.delay) } // ------------------------------------------------------------------- // animateup()- Move the two inner divs of the scroller up and in sync // ------------------------------------------------------------------- pausescroller.prototype.animateup=function(){ var scrollerinstance=this if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){ this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px" this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px" setTimeout(function(){scrollerinstance.animateup()}, 50) }else{ this.getinline(this.hiddendiv, this.visiblediv) this.swapdivs() setTimeout(function(){scrollerinstance.setmessage()}, this.delay) } } // ------------------------------------------------------------------- // swapdivs()- Swap between which is the visible and which is the hidden div // ------------------------------------------------------------------- pausescroller.prototype.swapdivs=function(){ var tempcontainer=this.visiblediv this.visiblediv=this.hiddendiv this.hiddendiv=tempcontainer } pausescroller.prototype.getinline=function(div1, div2){ div1.style.top=this.visibledivtop+"px" div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px" } // ------------------------------------------------------------------- // setmessage()- Populate the hidden div with the next message before it's visible // ------------------------------------------------------------------- pausescroller.prototype.setmessage=function(){ var scrollerinstance=this if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it) setTimeout(function(){scrollerinstance.setmessage()}, 100) else{ var i=this.hiddendivpointer var ceiling=this.content.length this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1 this.hiddendiv.innerHTML=this.content[this.hiddendivpointer] this.animateup() } } pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any if (tickerobj.currentStyle) return tickerobj.currentStyle["paddingTop"] else if (window.getComputedStyle) //if DOM2 return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top") else return 0 } </script> <script type="text/javascript"> //new pausescroller(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds) new pausescroller(pausecontent, "pscroller1", "someclass", 3000) document.write("<br />") new pausescroller(pausecontent2, "pscroller2", "someclass", 2000) </script> <!--************************************* 实例代码结束 *************************************--> </div> </body> </html>
本站所有特效都是站长亲自测试后发布的,如果运行代码无效果,请复制到您的本机运行
运行代码
复制代码
另存代码
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
转载请注明(B5教程网)原文链接::
https://b5.mxunkeji.com/content-68-177-1.html
相关热词搜索:
上一篇:
js文字特效篇--文字闪烁
下一篇:
js循环向上滚动特代码
最新推荐
[
网络推广
]
24h无人值守共享自助洗车解
[
网络推广
]
微信小程商家wifi码是什么?
[
网络推广
]
企业光伏数据对接碳达峰系统
[
互联网资讯
]
CentOS官方已计划停止维护Ce
[
PHP教程
]
PHP 主力开发因生活压力不
[
网络营销
]
抖音自动关注、自动点赞、自
[
网络推广
]
阿里云优惠券|阿里云代金券|
[
网络推广
]
阿里云 ECS实例升级、续费
[
互联网资讯
]
我名下有几张移动电话卡?有
[
互联网资讯
]
互联网平台相互屏蔽网址链接
本周排行
[
文字特效
]
DIV+CSS实现鼠标经过悬停在图片上时图片下方显示文字说明
[
文字特效
]
用css获取一串文字的第一个字,并将其定义为指定大小特效
[
文字特效
]
让一组数字随机显示位置
[
文字特效
]
javascript滚动公告板效果
[
文字特效
]
js文字特效篇--闪动的文字
[
文字特效
]
jquery-打字机效果
[
文字特效
]
旋转的文字
[
文字特效
]
简易的单数字随机抽奖,抽取随机数的js特效代码_文字特效
[
文字特效
]
文本向上滚动效果
[
文字特效
]
js文字提示效果
关于我们
关于我们
赞助我们
加入我们
版权声明
联系我们
联系我们
QQ技术群
合作方式
广告服务
业务合作
常见问题
意见反馈
网站地图
在线投稿
积分获取
在线充值
本站不承担任何版权问题,如果我们侵犯了您的利益,请来信
告知(634381967@qq.com),我们会在第一时间处理!
© 苏ICP备20040182号
B5教程网 版权所有