滚动的字幕,有停顿时间与背景设置.

XML/HTML代码
  1. <script language="JavaScript1.2">  
  2.   
  3. /*   
  4. Pausing updown message scroller-    
  5. Last updated: 99/07/05 (Bugs fixed, ability to specify background image for scroller)   
  6. ?Dynamic Drive (www.dynamicdrive.com)   
  7. For full source code, installation instructions,   
  8. 100's more DHTML scripts, and Terms Of   
  9. Use, visit dynamicdrive.com   
  10. */   
  11.   
  12. //这里配置滚动字幕的属性   
  13. var scrollerwidth=150  
  14. var scrollerheight=120  
  15. var scrollerbgcolor='lightyellow'  
  16. //set below to '' if you don't wish to use a background image   
  17. var scrollerbackground='scrollerback.gif'  
  18.   
  19. //设置内容   
  20. var messages=new Array()   
  21. messages[0]="<font face='Arial'><a href='../../../dynamicdrive.com/index.html'>Click here to go back to Dynamicdrive.com frontpage</a></font>"   
  22. messages[1]="<font face='Arial'><a href='../../../wsabstract.com/index.html'>Visit Website Abstraction for award winning JavaScript tutorials</a></font>"   
  23. messages[2]="<font face='Arial'><a href='../../../www.geocities.com/ResearchTriangle/Facility/4490'>Want to learn DHTML? Click here</a></font>"   
  24. messages[3]="<font face='Arial'><a href='../../../www.freewarejava.com/index.html'>Looking for Free Java applets? Visit Freewarejava.com!</a></font>"   
  25. messages[4]="<font face='Arial'><a href='../../../dynamicdrive.com/link.htm'>If you find this script useful, please click here to link back to Dynamic Drive!</a></font>"   
  26.   
  27. ///////不要修改下面的内容///////////////////////   
  28.   
  29. if (messages.length>1)   
  30. i=2  
  31. else   
  32. i=0  
  33.   
  34. function move1(whichlayer){   
  35. tlayer=eval(whichlayer)   
  36. if (tlayer.top>0&&tlayer.top<=5){   
  37. tlayer.top=0  
  38. setTimeout("move1(tlayer)",3000)   
  39. setTimeout("move2(document.main.document.second)",3000)   
  40. return   
  41. }   
  42. if (tlayer.top>=tlayer.document.height*-1){   
  43. tlayer.top-=5  
  44. setTimeout("move1(tlayer)",100)   
  45. }   
  46. else{   
  47. tlayer.top=scrollerheight  
  48. tlayer.document.write(messages[i])   
  49. tlayer.document.close()   
  50. if (i==messages.length-1)   
  51. i=0  
  52. else   
  53. i++   
  54. }   
  55. }   
  56.   
  57. function move2(whichlayer){   
  58. tlayer2=eval(whichlayer)   
  59. if (tlayer2.top>0&&tlayer2.top<=5){   
  60. tlayer2.top=0  
  61. setTimeout("move2(tlayer2)",3000)   
  62. setTimeout("move1(document.main.document.first)",3000)   
  63. return   
  64. }   
  65. if (tlayer2.top>=tlayer2.document.height*-1){   
  66. tlayer2.top-=5  
  67. setTimeout("move2(tlayer2)",100)   
  68. }   
  69. else{   
  70. tlayer2.top=scrollerheight  
  71. tlayer2.document.write(messages[i])   
  72. tlayer2.document.close()   
  73. if (i==messages.length-1)   
  74. i=0  
  75. else   
  76. i++   
  77. }   
  78. }   
  79.   
  80. function move3(whichdiv){   
  81. tdiv=eval(whichdiv)   
  82. if (tdiv.style.pixelTop>0&&tdiv.style.pixelTop<=5){   
  83. tdiv.style.pixelTop=0  
  84. setTimeout("move3(tdiv)",3000)   
  85. setTimeout("move4(second2)",3000)   
  86. return   
  87. }   
  88. if (tdiv.style.pixelTop>=tdiv.offsetHeight*-1){   
  89. tdiv.style.pixelTop-=5  
  90. setTimeout("move3(tdiv)",100)   
  91. }   
  92. else{   
  93. tdiv.style.pixelTop=scrollerheight  
  94. tdiv.innerHTML=messages[i]   
  95. if (i==messages.length-1)   
  96. i=0  
  97. else   
  98. i++   
  99. }   
  100. }   
  101.   
  102. function move4(whichdiv){   
  103. tdiv2=eval(whichdiv)   
  104. if (tdiv2.style.pixelTop>0&&tdiv2.style.pixelTop<=5){   
  105. tdiv2.style.pixelTop=0  
  106. setTimeout("move4(tdiv2)",3000)   
  107. setTimeout("move3(first2)",3000)   
  108. return   
  109. }   
  110. if (tdiv2.style.pixelTop>=tdiv2.offsetHeight*-1){   
  111. tdiv2.style.pixelTop-=5  
  112. setTimeout("move4(second2)",100)   
  113. }   
  114. else{   
  115. tdiv2.style.pixelTop=scrollerheight  
  116. tdiv2.innerHTML=messages[i]   
  117. if (i==messages.length-1)   
  118. i=0  
  119. else   
  120. i++   
  121. }   
  122. }   
  123.   
  124. function startscroll(){   
  125. if (document.all){   
  126. move3(first2)   
  127. second2.style.top=scrollerheight  
  128. second2.style.visibility='visible'  
  129. }   
  130. else if (document.layers){   
  131. document.main.visibility='show'  
  132. move1(document.main.document.first)   
  133. document.main.document.second.top=scrollerheight+5   
  134. document.main.document.second.visibility='show'  
  135. }   
  136. }   
  137.   
  138. window.onload=startscroll  
  139.   
  140. </script>  
  141.   
  142.   
  143.   
  144.   
  145. <ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor}; background=&{scrollerbackground}; visibility=hide>  
  146. <layer id="first" left=0 top=1 width=&{scrollerwidth};>  
  147. <script language="JavaScript1.2">  
  148. if (document.layers)   
  149. document.write(messages[0])   
  150. </script>  
  151. </layer><layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>  
  152. <script language="JavaScript1.2">  
  153. if (document.layers)   
  154. document.write(messages[1])   
  155. </script>  
  156. </layer></ilayer><script language="JavaScript1.2">  
  157. if (document.all){   
  158. document.writeln('<span id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hiden;background-color:'+scrollerbgcolor+' ;background-image:url('+scrollerbackground+')">')   
  159. document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0;top:0">')   
  160. document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:0;top:1;">')   
  161. document.write(messages[0])   
  162. document.writeln('</div>')   
  163. document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0;top:0;visibility:hidden">')   
  164. document.write(messages[1])   
  165. document.writeln('</div>')   
  166. document.writeln('</div>')   
  167. document.writeln('</span>')   
  168. }   
  169. </script>  

 



文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: 540
发表评论
昵 称: 注册帐号 密码: 游客直接输入昵称不需要密码
内 容:
验证码: 验证码