|
本文演示了ASP服務(wù)端腳本的幾個(gè)重要應(yīng)用.
目錄:
1. 遍歷集合/對(duì)象
1.1 VBScript 遍歷表單集合
1.2 JScript 遍歷表單集合
2. 轉(zhuǎn)變量值為變量, 并賦值
2.1 VBScript 轉(zhuǎn)變量值為變量并賦值
2.2 JScript 轉(zhuǎn)變量值為變量并賦值
3. 動(dòng)態(tài)包含文件
3.1 VBScript 動(dòng)態(tài)包含文件
3.2 JScript 動(dòng)態(tài)包含文件
shawl.qiu
2006-10-11
http://blog.csdn.NET/btbtd
1. 遍歷集合/對(duì)象
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. 轉(zhuǎn)變量值為變量, 并賦值
2.1 VBScript 轉(zhuǎn)變量值為變量并賦值
linenum
<%
for each temp in request.Form
execute temp&"=request.form(temp)"
next
%>
2.2 JScript 轉(zhuǎn)變量值為變量并賦值
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. 動(dòng)態(tài)包含文件
3.1 VBScript 動(dòng)態(tài)包含文件
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 動(dòng)態(tài)包含文件
linenum
<%
eval($dynInc('aj2.ASP'));
Response.Write($test);
function $dynInc($fl){
/* ------------------------------------/
* 服務(wù)端 JScript 動(dòng)態(tài)包含文件 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;
}
%>
JavaScript技術(shù):服務(wù)端 VBScript 與 JScript 幾個(gè)相同特性的寫法 By shawl.qiu,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。