就他吧-9ta8为您提供:身份证查询、15位转16位身份证,手机号码归属地查询,IP地址查询服务,城市天气预报查询,列车时刻表简易快速查询等等查询服务,就他吧欢迎您的光临!!

JavaScript常用小技巧—文字从状态栏冒出

1 文字从状态栏右边冒出
 1<html>
 2<head>
 3    <title>文字从状态栏右边冒出</title>
 4</head>
 5<body>
 6 
 7<script language="JavaScript"> 
 8<!-- 
 9function statusMessageObject(p,d) 
10  this.msg = MESSAGE 
11  this.out = " " 
12  this.pos = POSITION 
13  this.delay = DELAY 
14  this.i     = 0 
15  this.reset = clearMessage 
16}
 
17function clearMessage() 
18  this.pos = POSITION 
19}
 
20var POSITION = 100 
21var DELAY    = 4 
22 var MESSAGE  = "状态栏文字快速的一个一个弹出!!!    "  
23var scroll = new statusMessageObject() 
24function scroller() 
25  for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++
26    scroll.out += " " 
27  }
 
28  if (scroll.pos >= 0
29   scroll.out += scroll.msg 
30  else scroll.out = scroll.msg.substring(-scroll.pos,scroll.msg.length) 
31  window.status = scroll.out 
32  scroll.out = " " 
33  scroll.pos-- 
34  if (scroll.pos < -(scroll.msg.length)) 
35   scroll.reset() 
36  }
 
37  setTimeout ("scroller()",scroll.delay) 
38}
 
39function snapIn(jumpSpaces,position) 
40  var msg = scroll.msg 
41  var out = "" 
42  for (var i=0; i<position; i++)  
43    {out += msg.charAt(i)} 
44  for (i=1;i<jumpSpaces;i++)  
45    {out += " "} 
46  out += msg.charAt(position) 
47  window.status = out 
48  if (jumpSpaces <= 1
49    position++ 
50    if (msg.charAt(position) == " ")  
51      {position++ } 
52    jumpSpaces = 100-position 
53  }
 else if (jumpSpaces >  3
54       {jumpSpaces *= .75} 
55  else 
56    {jumpSpaces--} 
57  if (position != msg.length) 
58    var cmd = "snapIn(" + jumpSpaces + "," + position + ")"
59    scrollID = window.setTimeout(cmd,scroll.delay); 
60  }
 else 
61    window.status="" 
62    jumpSpaces=0 
63    position=0 
64    cmd = "snapIn(" + jumpSpaces + "," + position + ")"
65    scrollID = window.setTimeout(cmd,scroll.delay); 
66    return false  
67  }
 
68  return true 
69}
 
70snapIn(100,0); 
71// --> 
72
</script>  
73
74</body>
75</html> 

2 文字从状态栏左边冒出
 1<html>
 2<head>
 3    <title>文字从状态栏左边冒出</title>
 4</head>
 5<body>
 6 
 7<script language="JavaScript"> 
 8var msg  = "状态栏文字从左一个一个冒出!!      " ; 
 9var interval = 120 
10var spacelen = 120
11var space10=" "
12var seq=0
13function Scroll() 
14len = msg.length; 
15window.status = msg.substring(0, seq+1); 
16seq++
17if ( seq >= len ) {  
18seq = 0;  
19window.status = ""
20window.setTimeout("Scroll();", interval ); 
21}
 
22else 
23window.setTimeout("Scroll();", interval ); 
24}
  
25Scroll(); 
26
</script> 
27</body>
28</html> 

3 文字在状态栏逐字放入
 1<html>
 2<head>
 3    <title>文字在状态栏逐字放入</title>
 4</head>
 5<body>
 6 
 7<script language="JavaScript"> 
 8<!-- 
 9function statusMessageObject(p,d) 
10  this.msg = MESSAGE 
11  this.out = " " 
12  this.pos = POSITION 
13  this.delay = DELAY 
14  this.i     = 0 
15  this.reset = clearMessage 
16}
 
17function clearMessage() 
18  this.pos = POSITION 
19}
 
20var POSITION = 100 
21var DELAY    = 4 
22 var MESSAGE  = "状态栏文字快速的一个一个弹出!!!    "  
23var scroll = new statusMessageObject() 
24function scroller() 
25  for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++
26    scroll.out += " " 
27  }
 
28  if (scroll.pos >= 0
29   scroll.out += scroll.msg 
30  else scroll.out = scroll.msg.substring(-scroll.pos,scroll.msg.length) 
31  window.status = scroll.out 
32  scroll.out = " " 
33  scroll.pos-- 
34  if (scroll.pos < -(scroll.msg.length)) 
35   scroll.reset() 
36  }
 
37  setTimeout ("scroller()",scroll.delay) 
38}
 
39function snapIn(jumpSpaces,position) 
40  var msg = scroll.msg 
41  var out = "" 
42  for (var i=0; i<position; i++)  
43    {out += msg.charAt(i)} 
44  for (i=1;i<jumpSpaces;i++)  
45    {out += " "} 
46  out += msg.charAt(position) 
47  window.status = out 
48  if (jumpSpaces <= 1
49    position++ 
50    if (msg.charAt(position) == " ")  
51      {position++ } 
52    jumpSpaces = 100-position 
53  }
 else if (jumpSpaces >  3
54       {jumpSpaces *= .75} 
55  else 
56    {jumpSpaces--} 
57  if (position != msg.length) 
58    var cmd = "snapIn(" + jumpSpaces + "," + position + ")"
59    scrollID = window.setTimeout(cmd,scroll.delay); 
60  }
 else 
61    window.status="" 
62    jumpSpaces=0 
63    position=0 
64    cmd = "snapIn(" + jumpSpaces + "," + position + ")"
65    scrollID = window.setTimeout(cmd,scroll.delay); 
66    return false  
67  }
 
68  return true 
69}
 
70snapIn(100,0); 
71// --> 
72
</script>  
73
74</body>
75</html> 


如果大家还有其他的方式可以补充。
posted on 2005-08-07 17:49  振河  阅读(948)  评论(1编辑  收藏  举报

  就他吧-9ta8伴您开心每一天