<script language="vbscript" runat="server">
Sub WriteNameA(name)
Response.Write("My name is " + name + ".")
End Sub
Function WriteNameB(name)
WriteNameB = "My name is " + name + "."
End Function
</script>
<script language="javascript" runat="server">
function WriteNameC(name)
{
Response.Write("My name is " + name + ".")
}
function WriteNameD(name)
{
return "My name is " + name + "."
}
</script>
<%
'调用VBScript子过程
Call WriteNameA("NameA")
WriteNameA "NameA"
'调用VBScript函数
Response.Write(WriteNameB("NameB"))
'调用JavaScript函数
WriteNameC("NameC")
Response.Write(WriteNameD("NameD"))
%>从例子中我们可以看出:
·VBScript有子过程(Sub)和函数(Function)之分,JavaScript只有函数;
·VBScript的子过程通常没有返回值,函数通常有返回值;
·JavaScript的函数既可以有返回值,也可以没有返回值;
·调用子过程可以用Call,也可以不用,用Call时必须将参数放在括号中,不用Call时过程名后直接跟参数;
·调用函数的方式为"函数名(参数列表)";
·同一个页面中可以同时使用VBScript和JavaScript!
评论(0)
暂无评论。