服务端 VBScript 与 JScript 几个相同特性的写法与示例
程序员文章站
2023-01-03 22:33:15
by shawl.qiu 摘要: 本文演示了asp服务端脚本的几个重要应用. 目录: 1. 遍历集合/对象 1.1 vbscrip...
by shawl.qiu
摘要:
本文演示了asp服务端脚本的几个重要应用.
目录:
1. 遍历集合/对象
1.1 vbscript 遍历表单集合
1.2 jscript 遍历表单集合
2. 转变量值为变量, 并赋值
2.1 vbscript 转变量值为变量并赋值
2.2 jscript 转变量值为变量并赋值
3. 动态包含文件
3.1 vbscript 动态包含文件
3.2 jscript 动态包含文件
shawl.qiu
2006-10-11
http://blog.csdn.net/btbtd
1. 遍历集合/对象
1.1 vbscript 遍历表单集合
linenum
<%
for each temp in request.form
response.write temp&": "&request.form(temp)
next
%>
1.2 jscript 遍历表单集合
linenum
<%
for (var $e=new enumerator(request.form); !$e.atend(); $e.movenext()){
response.write($e.item()+':<br/> '+request.form($e.item()));
}
%>
2. 转变量值为变量, 并赋值
2.1 vbscript 转变量值为变量并赋值
linenum
<%
for each temp in request.form
execute temp&"=request.form(temp)"
next
%>
2.2 jscript 转变量值为变量并赋值
linenum
<%
var $xml=new activexobject("microsoft.xmldom");
$xml.load(server.mappath('config.xml'));
var $childnodes=$xml.documentelement.selectsinglenode('//siteconfig').childnodes
for ($e=new enumerator($childnodes); !$e.atend(); $e.movenext()){
eval($e.item().nodename+"=$e.item().text");
}
$xml=null;
response.write(sitekeywords);
%>
3. 动态包含文件
3.1 vbscript 动态包含文件
linenum
<%
function finclude(filepath)
' sample call '''/// execute finclude("include/system/language/"&sitefglang&"/main.asp") \\\'''
dim cnt
cnt=createobject("scripting.filesystemobject").opentextfile(server.mappath(filepath)).readall
cnt=replace(cnt,"<"&chr(37),"")
cnt=replace(cnt,chr(37)&">","")
finclude=cnt
end function 'shawl.qiu code'
execute finclude("include/system/language/"&sitefglang&"/main.asp")
%>
3.2 jscript 动态包含文件
linenum
<%
eval($dyninc('aj2.asp'));
response.write($test);
function $dyninc($fl){
/* ------------------------------------\
* 服务端 jscript 动态包含文件 by shawl.qiu
* sample call: eval($dyninc('aj2.asp'));
\*------------------------------------*/
var $fso=new activexobject("scripting.filesystemobject");
$str=$fso.opentextfile(server.mappath($fl)).readall();
$str=$str.replace(/\<\%|\%\>/g,'');
$fso=null;
return $str;
}
%>
摘要:
本文演示了asp服务端脚本的几个重要应用.
目录:
1. 遍历集合/对象
1.1 vbscript 遍历表单集合
1.2 jscript 遍历表单集合
2. 转变量值为变量, 并赋值
2.1 vbscript 转变量值为变量并赋值
2.2 jscript 转变量值为变量并赋值
3. 动态包含文件
3.1 vbscript 动态包含文件
3.2 jscript 动态包含文件
shawl.qiu
2006-10-11
http://blog.csdn.net/btbtd
1. 遍历集合/对象
1.1 vbscript 遍历表单集合
linenum
<%
for each temp in request.form
response.write temp&": "&request.form(temp)
next
%>
1.2 jscript 遍历表单集合
linenum
<%
for (var $e=new enumerator(request.form); !$e.atend(); $e.movenext()){
response.write($e.item()+':<br/> '+request.form($e.item()));
}
%>
2. 转变量值为变量, 并赋值
2.1 vbscript 转变量值为变量并赋值
linenum
<%
for each temp in request.form
execute temp&"=request.form(temp)"
next
%>
2.2 jscript 转变量值为变量并赋值
linenum
<%
var $xml=new activexobject("microsoft.xmldom");
$xml.load(server.mappath('config.xml'));
var $childnodes=$xml.documentelement.selectsinglenode('//siteconfig').childnodes
for ($e=new enumerator($childnodes); !$e.atend(); $e.movenext()){
eval($e.item().nodename+"=$e.item().text");
}
$xml=null;
response.write(sitekeywords);
%>
3. 动态包含文件
3.1 vbscript 动态包含文件
linenum
<%
function finclude(filepath)
' sample call '''/// execute finclude("include/system/language/"&sitefglang&"/main.asp") \\\'''
dim cnt
cnt=createobject("scripting.filesystemobject").opentextfile(server.mappath(filepath)).readall
cnt=replace(cnt,"<"&chr(37),"")
cnt=replace(cnt,chr(37)&">","")
finclude=cnt
end function 'shawl.qiu code'
execute finclude("include/system/language/"&sitefglang&"/main.asp")
%>
3.2 jscript 动态包含文件
linenum
<%
eval($dyninc('aj2.asp'));
response.write($test);
function $dyninc($fl){
/* ------------------------------------\
* 服务端 jscript 动态包含文件 by shawl.qiu
* sample call: eval($dyninc('aj2.asp'));
\*------------------------------------*/
var $fso=new activexobject("scripting.filesystemobject");
$str=$fso.opentextfile(server.mappath($fl)).readall();
$str=$str.replace(/\<\%|\%\>/g,'');
$fso=null;
return $str;
}
%>