我的位置:首页 综合讨论 薏米杂谈 脚本测试

脚本测试

1273
0

liyi674254133 小试身手Lv3

发表于2019-10-11 12:11

楼主
  1. <title>JavaScript实现的动态文字效果</title>
  2. <body>
  3. <script language="JavaScript">
  4. message="→悬赏走一走2333!"
  5. ns6switch=1
  6. var ns6=document.getElementById && !document.all
  7. mes=new Array();
  8. mes[0]=-1;
  9. mes[1]=-4;
  10. mes[2]=-7;mes[3]=-10;
  11. mes[4]=-7;
  12. mes[5]=-4;
  13. mes[6]=-1;
  14. num=0;
  15. num2=0;
  16. txt="";
  17. function jump0(){
  18. if (ns6 && !ns6switch){
  19. jump.innerHTML=message
  20. return
  21. }
  22. if(message.length > 6){
  23. for(i=0; i != message.length;i++){
  24. txt=txt+"<span style='position:relative;' id='n"+i+"'>"+message.charAt(i)+"</span>"};
  25. jump.innerHTML=txt;
  26. txt="";
  27. jump1a()
  28. }
  29. else{
  30. alert("Your message is to short")
  31. }
  32. }

  33. function jump1a(){
  34. nfinal=(document.getElementById)? document.getElementById("n0") : document.all.n0
  35. nfinal.style.left=-num2;
  36. if(num2 != 9){
  37. num2=num2+3;
  38. setTimeout("jump1a()",50)
  39. }
  40. else{
  41. jump1b()
  42. }
  43. }

  44. function jump1b(){
  45. nfinal.style.left=-num2;
  46. if(num2 != 0){num2=num2-3;
  47. setTimeout("jump1b()",50)
  48. }
  49. else{
  50. jump2()
  51. }
  52. }

  53. function jump2(){
  54. txt="";
  55. for(i=0;i != message.length;i++){
  56. if(i+num > -1  &&  i+num < 7){
  57. txt=txt+"<span style='position:relative;top:"+mes[i+num]+"'>"+message.charAt(i)+"</span>"
  58. }
  59. else{txt=txt+"<span>"+message.charAt(i)+"</span>"}
  60. }
  61. jump.innerHTML=txt;
  62. txt="";
  63. if(num != (-message.length)){
  64. num--;
  65. setTimeout("jump2()",50)}
  66. else{num=0;
  67. setTimeout("jump0()",50)}}
  68. </script>
  69. <h2><div id="jumpx" style="color:green"></div></h2>
  70. <script>
  71. if (document.all||document.getElementById){
  72. jump=(document.getElementById)? document.getElementById("jumpx") : document.all.jumpx
  73. jump0()
  74. }
  75. else
  76. document.write(message)
  77. </script>
  78. </body>

复制代码

最近看过此主题的会员

hero851815

0个回答

只看楼主

登录后可回答问题,请登录注册

快速回复 返回顶部 返回列表

小时

全天响应

分钟

快速处理问题

工程师强势助力

明星产品
解决方案
联系合作

400咨询:400-0011-866

技术支持QQ:400-0011-866(工作日9:00-18:00)

产品建议邮箱yixin@esensoft.com

关注我们

扫TA学习更多干货

一对一专家交流

版权所有© 2006-2024 北京亿信华辰软件有限责任公司 京ICP备07017321号 京公网安备11010802016281号