📄 多变的状态栏文字.htm
字号:
<HTML>
<HEAD>
<META name="VI60_DefaultClientScript" Content="VBScript">
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>多变的状态栏文字</TITLE>
</HEAD>
<script LANGUAGE="VBScript">
<!--
'定义计时器变量tid
dim tid
'定义用于滚动状态栏的滚动信息
dim scroll_msg,scroll_out,scroll_pos,scroll_delay
'滚动信息
scroll_msg ="欢迎你使用VBScript编程百例 "
'用于真正显示的字符串
scroll_out = ""
'滚动字符串的首部位置
scroll_pos = 100
'滚动间隔
scroll_delay = 5
'滚动状态栏过程
sub scroller
'在有效字符串首部位置前添加空格
for i = 1 to scroll_pos
scroll_out = scroll_out &" "
next
'如果scroll_pos大于0,则将空格0与有效字符串相接
if scroll_pos>0 then
scroll_out = scroll_out & scroll_msg
else
'否则,显示有效字符串的一部分
scroll_out = mid(scroll_msg,-scroll_pos+1,len(scroll_msg))
end if
'显示字符串
window.status = scroll_out
'清空scroll_out
scroll_out = " "
'位置变量减1
scroll_pos=scroll_pos-1
'如果位置变量小于负的有效字符串长度,则还原位置变量
if scroll_pos < -len(scroll_msg) then scroll_pos = 100
'循环反复
tid=setTimeout ("scroller()",scroll_delay)
end sub
'雨点状态栏过程
function snapIn(jumpSpaces,position)
'定义有效字符串
dim msg
msg= scroll_msg
'定义显示字符串
dim out
out = ""
'下面生成用于显示的字符串
'添加已经落下的雨点字
for i=1 to position
out =out&mid(msg,i,1)
next
'添加新的雨点字前面的空格,即落地距离
for i=1 to jumpSpaces-1
out = out&" "
next
'添加雨点字
out = out&mid(msg,position+1,1)
'显示字符串out
window.status = out
'如果落地距离小于等于1,即已经落地
if (jumpSpaces <= 1) then
'则已经落下的雨点字字符串尾部位置加1
position=position+1
'如果下一个雨点字是空格,则向下挪一位
if mid(msg,position,1) = " " then position=position+1
'设置新的落地距离,每次从同一高度下落,总距离保持100
jumpSpaces = 100-position
else
'如果没有落地,处理落地速度,这个速度和自由落体相反,越到后面越慢
'如果落地距离大于3
if (jumpSpaces > 3) then
'每次以缩短原先距离的25%的速度下落
jumpSpaces =jumpSpaces*0.75
else
'否则,以每次减1的速度下落
jumpSpaces=jumpSpaces-1
end if
end if
'如果已经落地的雨点字字符串小于有效字符串的显示长度
if (position < len(msg)) then
'则继续反复调用此过程
cmd = "snapIn " & jumpSpaces & "," &position
TID = window.setTimeout(cmd,scroll_delay)
else
'否则证明一次降落完成,将所有状态恢复为开始时的状态
window.status=""
jumpSpaces=100
position=1
'反复调用过程让整个过程循环进行
cmd = "snapIn " & jumpSpaces & "," & position
TID = window.setTimeout(cmd,scroll_delay)
end if
end function
-->
</script>
<SCRIPT LANGUAGE="VBScript">
'定义速度
dim speed
speed= 200
'定义用于显示的多行字符串数组
dim messages(2)
messages(0) = "欢迎你使用VBScript编程百例"
messages(1) = "有问题请和本出版社联系"
messages(2) = "谢谢你的支持"
'定义当前正显示的字符串在字符串数组中的位置指针
dim currentMessage
currentMessage= 0
'定义偏移变量
dim offset
offset= 0
'多行舒展式状态栏过程
sub showBanner
'决定字符串数组中哪一行正在显示
dim text
text=messages(currentMessage)
'偏移变量如果小于该行的有效字符串长度
if offset < len(text) then
'如果下一个字符为""则偏移变量加1
if mid(text,offset+1,1)=" " then offset=offset+1
'定义实际显示的字符串变量
dim partialMessage
'生成用于显示的字符串,并赋给状态栏
partialMessage = mid(text,1, offset+1)
window.status = partialMessage
'偏移变量加1
offset=offset+1
TID = setTimeout("showBanner", speed)
else
'偏移值赋0
offset = 0
'数组指针下移,显示下一行字符串
currentMessage=currentMessage+1
'如果数组指针大于数组上界,则回0
if (currentMessage > Ubound(messages)) then currentMessage = 0
'反复调用本过程
TID = setTimeout("showBanner", pause)
end if
end sub
</SCRIPT>
<BODY bgColor=peachpuff>
<center>
<h1><font color=red>文字显示状态</font></h1>
<INPUT type=button value="雨 点 式" id=button2 name=button2 onclick="clearTimeout(tid):snapin 100,1">
<br><br>
<INPUT type=button value="多行舒展式" id=button3 name=button3 onclick="clearTimeout(tid):showBanner">
</center>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -