当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP Procedures

ASP
ASP 介绍
ASP Install
ASP 语法
ASP 变量
ASP Procedures
ASP Forms
ASP Cookies
ASP Session
ASP Application
ASP #include
ASP Global.asa
ASP Send e-mail
ASP Response
ASP Request
ASP Application
ASP Session
ASP Server
ASP Error
ASP FileSystem
ASP TextStream

ASP Procedures


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 877 ::
收藏到网摘: n/a

In ASP you can call a JavaScript procedure from a VBScript and vice versa.
在ASP中,你可以在“VBScript”脚本中调用“JavaScript”子程序;同样的,反过来也可以。


 

Examples 实例

Call a procedure using VBScript
通过“VBScript”调用一条子程序
How to call a VBScript procedure from ASP.
如何通过“VBScript”调用ASP中的一条子程序

Call a procedure using JavaScript
通过“JavaScript”调用一条子程序
How to call a JavaScript procedure from ASP.
如何通过“JavaScript”调用ASP中的一条子程序

Call procedures using VBScript
如何通过“VBScript”同时调用ASP中的“JavaScript”子程序和“VBScript”子程序
How to call both a JavaScript procedure and a VBScript procedure in an ASP file.


 

Procedures 子程序

The ASP source code can contain procedures and functions:
ASP的源代码中可以同时包含“Sub”子程序和“Function”函数,举例如下:

<html>
<head>
<%
sub vbproc(num1,num2)
response.write(num1*num2)
end sub
%>
</head>
<body>
<p>Result: <%call vbproc(3,4)%></p>
</body>
</html>

Insert the <%@ language="language" %> line above the <html> tag to write procedures or functions in another scripting language than default:
如果在<html>标签的上方插入<% @ language=”language” %>,那么,在ASP中书写“Sub”子程序和“Function”函数时,默认的脚本语言将会被改成设置后的语言,举例如下:

<%@ language="javascript" %>
<html>
<head>
<%
function jsproc(num1,num2)
{
Response.Write(num1*num2)
}
%>
</head>
<body>
<p>Result: <%jsproc(3,4)%></p>
</body>
</html>


Differences Between VBScript and JavaScript
“VBscript”和“JavaScript”的区别:

When calling a VBScript or a JavaScript procedure from an ASP file written in VBScript, you can use the "call" keyword followed by the procedure name. If a procedure requires parameters, the parameter list must be enclosed in parentheses when using the "call" keyword. If you omit the "call" keyword, the parameter list must not be enclosed in parentheses. If the procedure has no parameters, the parentheses are optional.
经过上面例子的演示,各位需要注意一下“VBScript”和“JavaScript”的区别:
1、在书写ASP文件时,当你希望用“VBScript”脚本来调用“VBScript”程序或是“JavaScript”程序时,你可以在关键字“Call”的后面加上子程序的名字来调用;如果这个子程序存在参数,那么,当你用“Call”来调用这个子程序时,参数必须要写在括弧“()”内;但是,如果你省略了关键词“Call”,那么书写参数时可以不必加括弧“()”;如果子程序的本身不带有参数,那么写不写括弧“()”都无所谓

When calling a JavaScript or a VBScript procedure from an ASP file written in JavaScript, always use parentheses after the procedure name. 
2、在书写ASP文件时,当你希望用“JavaScript”脚本来调用“VBScript”程序或是“JavaScript”程序时,在子程序的名字后面必须要加括弧“()”。

评论 (0) All

登陆 | 还没注册?