首页 > 其他分享 >一段动态滚动公告栏的js代码

一段动态滚动公告栏的js代码

时间:2023-09-18 10:06:51浏览次数:42  
标签:style 滚动 公告栏 top messages js else document tlayer2


代码如下:

<span style='visibility:hidden;'>
<span id="pm1">
公园小路上,男正对女发誓。
男:我爱你,直到大海干枯。
女:不行,冰川期到时,海平面回下降。
男:我爱你,直到地球毁灭。
女:不行,一颗慧星撞过来,地球就没了。
男:我爱你,直到中国电信实行手机单向收费!
女:太美了。
接吻声————————————————————
</span>
<span id="pm2">
傻女婿从前有个傻女婿。
有一天他岳父要来拜访,父亲刚好要出远门,不放心,所以就教他,
如果你岳父问你:"这些院子的牛马是怎麽照顾的,长得这麽好。"
你就说:"小小畜牲何必介意!"
如果他问你:"家中事业是谁在管理的?"
你就说:"小婿无能父亲掌管!"
如果问起墙上那幅画,就说:"这是唐伯虎名画。"
还叫他覆颂了一遍,才放心离开。</span>
<span id="pm3">
有一名贵妇养了一只母鹦鹉,但这只鹦鹉只会说:「来ㄚ!要不要爽一下ㄚ......」
贵妇觉的这鹦鹉的行为实在有辱她的身份有日贵妇看到对面教堂的神父也养了一只公鹦鹉,而且很乖的在笼子里祷告
於是便去请教神父:「为何你的鹦鹉那麽乖?养多久啦?
我把我家的鹦鹉给你调教好吗?」神父:「我养两年啦,它ㄧ直都很乖,你的鹦鹉怎麽啦?」</span>
<span id="pm4">
儿子提著一个很大的提包,对爸爸说:「这个家我再也忍受不下去<BR>了。我要离开,我要自己去过那种天天有刺激,天天花天酒地,<BR>天天有漂亮妹妹的生活。爸爸,你无论如何都不能阻挠我。」<BR>爸爸一听,急急忙忙的说:「谁会阻挠你呀,我马上准备行李跟<BR>你一起去。」<BR>
</span>
</span>
<SCRIPT language=JavaScript1.2>
/// ················///
var scrollFlag=1;var scrollerwidth=568
var scrollerheight=150
var scrollerbgcolor=''//set below to '' if you don't wish to use a background image
var scrollerbackground='images/n_img/index_meuu_12.jpg'//configure the below variable to change the contents of the scroller
var messages=new Array()
messages[0]=pm1.innerHTML
messages[1]=pm2.innerHTML
messages[2]=pm3.innerHTML
messages[3]=pm4.innerHTML
///alert(messages[0]);
///Do not edit pass this line///if (messages.length>1)
i=2
else
i=0function move1(whichlayer){
tlayer=eval(whichlayer)
if (tlayer.top>0&&tlayer.top<=5){
tlayer.top=0
setTimeout("move1(tlayer)",3500)
setTimeout("move2(document.main.document.second)",3500)
return
}
if (tlayer.top>=tlayer.document.height*-1){

if(scrollFlag==1)tlayer.top-=5
setTimeout("move1(tlayer)",100)
}
else{
tlayer.top=scrollerheight
tlayer.document.write(messages[i])
tlayer.document.close()
if (i==messages.length-1)
i=0
else
i++
}}
function move2(whichlayer){
tlayer2=eval(whichlayer)
if (tlayer2.top>0&&tlayer2.top<=5){
tlayer2.top=0
setTimeout("move2(tlayer2)",3500)
setTimeout("move1(document.main.document.first)",3500)
return
}
if (tlayer2.top>=tlayer2.document.height*-1){
if(scrollFlag==1)tlayer2.top-=5
setTimeout("move2(tlayer2)",100)
}
else{
tlayer2.top=scrollerheight
tlayer2.document.write(messages[i])
tlayer2.document.close()
if (i==messages.length-1)
i=0
else
i++
}}
function move3(whichdiv){
tdiv=eval(whichdiv)
if (tdiv.style.pixelTop>0&&tdiv.style.pixelTop<=5){
tdiv.style.pixelTop=0
setTimeout("move3(tdiv)",3500)
setTimeout("move4(second2)",3500)
return
}
if (tdiv.style.pixelTop>=tdiv.offsetHeight*-1){

if(scrollFlag==1)tdiv.style.pixelTop-=5
setTimeout("move3(tdiv)",100)
}
else{
tdiv.style.pixelTop=scrollerheight
tdiv.innerHTML=messages[i]
if (i==messages.length-1)
i=0
else
i++
}}
function move4(whichdiv){
tdiv2=eval(whichdiv)
if (tdiv2.style.pixelTop>0&&tdiv2.style.pixelTop<=5){
tdiv2.style.pixelTop=0
setTimeout("move4(tdiv2)",3500)
setTimeout("move3(first2)",3500)
return
}
if (tdiv2.style.pixelTop>=tdiv2.offsetHeight*-1){
if(scrollFlag==1)tdiv2.style.pixelTop-=5
setTimeout("move4(second2)",100)
}
else{
tdiv2.style.pixelTop=scrollerheight
tdiv2.innerHTML=messages[i]
if (i==messages.length-1)
i=0
else
i++
}}
function startscroll(){
if (document.all){
move3(first2)
second2.style.top=scrollerheight
second2.style.visibility='visible'
}
else if (document.layers){
document.main.visibility='show'
move1(document.main.document.first)
document.main.document.second.top=scrollerheight+5
document.main.document.second.visibility='show'
}}
window.οnlοad=startscroll
function eMouseover()
{
   scrollFlag=0;
}
function eMouseout()
{
   scrollFlag=1;
}</SCRIPT>
<SCRIPT language=JavaScript1.2>
if (document.layers)
document.write(messages[0])
</SCRIPT><SCRIPT language=JavaScript1.2>
if (document.layers)
document.write(messages[1])
</SCRIPT><SCRIPT language=JavaScript1.2>
if (document.all){
document.writeln('<span id="main2" οnmοuseοver="eMouseover();"  οnmοuseοut="eMouseout();" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hiden;background-color:'+scrollerbgcolor+' ;background-image:url('+scrollerbackground+')">')
document.writeln('<div  style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0;top:0" > ')
document.writeln('<div  id="first2" style="position:absolute;width:'+scrollerwidth+';left:0;top:1;">')
document.write(messages[0])
document.writeln('</div>')
document.writeln('<div  id="second2" style="position:absolute;width:'+scrollerwidth+';left:0;top:0;visibility:hidden">')
document.write(messages[1])
document.writeln('</div>')
document.writeln('</div>')
document.writeln('</span>')
}
</SCRIPT>

标签:style,滚动,公告栏,top,messages,js,else,document,tlayer2
From: https://blog.51cto.com/u_8215601/7507393

相关文章

  • 在一个js文件中包含另一个js文件的方法
    ---------a.htm---------<scriptlanguage='javascript'src="a.js"></script><scriptlanguage="javascript">jin();liu();</script>--------a.js--------document.write("<scriptlanguage=&#......
  • 当页面中文本不允许选择时,使文本框中文本可以选择的js代码
    <bodyonselectstart="returnoSelect(event.srcElement);"><scriptlanguage="javascript">functionoSelect(obj){if(obj.type!='text')returnfalse;}</script><inputtype="text"name=&quo......
  • 按下按钮后页面的滚动条向下(或向上)滑动,松开之后便停留在当前位置的效果如何实现?
    网友问题?客户要求做一个框架,按下小框架页面中的“上翻”或者“下翻”按钮后,大框架页面便随之向上(或向下)滚动,松开按钮滚动停止,并停留在当前位置,如何解决?解决方案如下:-----------------mm.htm:-----------------<framesetrows="*,20%"><framename="main"src='liu.htm'target="fo......
  • JS装饰器模式,让你的代码更优雅
    装饰器模式JavaScript装饰器模式是一种常用的设计模式,它可以让你在不改变原有代码的情况下,动态地给对象添加新的功能。本文将通过一个实际的例子来介绍JavaScript装饰器模式的使用方法和优势。装饰器模式的定义装饰器模式是一种结构型设计模式,它允许你在运行时动态地给一个对象......
  • 题解 LOJ2549【[JSOI2018] 战争】
    problem给你两个平面凸多边形\(A,B\),\(Q\)次询问,每次询问是一个向量\(\vecv\),回答\(A\)与\(B+\vecv\)是否有交。\(n,Q\leq10^5\)。solution观察闵可夫斯基和(Minkowskysum)的定义,若将这个运算定义为\((*)::[Point]\to[Point]\to[Point]\),则满足:\[A*B=\{......
  • Linux管理多版本node.js
    这里介绍的是Linux版本的nvm工具:一个nodejs版本管理工具!这里可以灵活切换node指定版本哟~下载地址:https://github.com/nvm-sh/nvm/releases/1.安装需要先安装git、curlyuminstall-ygitcurl这里很慢,需要登录。如果不小心退出来,需要重新执行一下安装脚步:这时候需要......
  • Vue js 框下制作登录页面的新方法
    ......
  • JS防抖和节流
    引言:在前端开发中,性能优化是至关重要的。在处理用户输入、滚动事件、表单提交以及其他频繁触发的操作时,防抖和节流是两个常用的技术,用来减少不必要的资源消耗和提高用户体验。什么是防抖和节流?防抖:它限制了一个函数在连续触发事件后的执行次数。如果在一段时间内多次触发同一......
  • JS计算数组层级(深度)
    如果有一个多层嵌套的数组,想要计算其层级(深度),可以使用递归或迭代方法来实现。以下是两种常用的方法示例:递归方法:functioncalculateDepth(arr){if(!Array.isArray(arr)){return0;//如果不是数组,返回0表示不是层级结构}letmaxDepth=0;for(const......
  • 添加Element ui依赖报错:npm ERR code EPERM,syscall mkdir, npm ERR! path D:\Vue\
    添加Elementui依赖报错:npmERRcodeEPERM,syscallmkdir,npmERR!pathD:\Vue\nodejs\node_cache\_cacache\index-v5\f3\de具体报错信息如下:我这个是在IDEA控制台输入npmielement-ui-S添加elementui依赖时出现的报错解决办法:修改nodejs(安装node的安装地址那里)......