VBScript学习1源码
<html> <head> <script type="text/vbscript"> alert("it is the heard") document.write("alert是用窗口提醒内容的函数"&"<br />") sub mysub() msgbox("这是一段子程序。") end sub function myFunction() myFunction="红色" end function </script> </head> <body> <script type="text/vbscript"> document.write("it is not too bad!\n"&"<br />") document.write("在页面加载时,会执行body部分的脚本。"&"<br />") dim name name="wly eos" document.write(name&"<br />") document.write(name&"的职业为教师"&"<br />") private age age="22" document.write(age&"<br />") dim fname(5) fname(0)="lily" fname(1)="meimei" fname(2)="lucy" fname(3)="liming" fname(4)="wangtao" for i=0 to 5 document.write(fname(i)&"<br />") next dim table(4,6) call mysub() document.write("我喜欢的颜色是:"&myFunction()&"<br />") color=myFunction() document.write("我喜欢的颜色为:"&color) msgbox"my favoriate color is:"&myFunction() MyProc myFunction() </script> <p>函数程序可返回结果。</p> <p>子程序不返回结果。</p> <p> 通常,我们在head部分放置函数。理由是,可以确保函数在调用前已经加载。 </p> </body> </html>
编译结果:从左到右,从上到下显示出来的。