1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
<script type = "text/javascript"> var POSITION = 100; var DELAY = 5; var MESSAGE = "欢迎光临! Welcome to WWW.HELPOR.NET "; var scroll = new statusMessageObject(); function statusMessageObject(p, d) { this.msg = MESSAGE; this.out = " "; this.pos = POSITION; this.delay = DELAY; this.i = 0; this.reset = clearMessage; } function clearMessage() { this.pos = POSITION; } function scroller() { for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++) { scroll.out += " "; } if (scroll.pos >= 0) { scroll.out += scroll.msg; } else { scroll.out = scroll.msg.substring(-scroll.pos, scroll.msg.length); } window.status = scroll.out; scroll.out = " "; scroll.pos--; if (scroll.pos < -(scroll.msg.length)) { scroll.reset(); } setTimeout('scroller()', scroll.delay); } function snapIn(jumpSpaces, position) { var msg = scroll.msg; var out = ""; for (var i = 0; i < position; i++) { out += msg.charAt(i); } for (i = 1; i < jumpSpaces; i++) { out += " "; } out += msg.charAt(position); window.status = out; if (jumpSpaces <= 1) { position++; if (msg.charAt(position) == ' ') { position++; } jumpSpaces = 100 - position; } else if (jumpSpaces > 3) { jumpSpaces *= .75; } else { jumpSpaces--; } if (position != msg.length) { var cmd = "snapIn(" + jumpSpaces + "," + position + ")"; scrollID = window.setTimeout(cmd, scroll.delay); } else { window.status = ""; jumpSpaces = 0; position = 0; cmd = "snapIn(" + jumpSpaces + "," + position + ")"; scrollID = window.setTimeout(cmd, scroll.delay); return false } return true } snapIn(100, 0); </script> |