服務(wù)端 VBScript 與 JScript 幾個相同特性的寫法與示例
更新時間:2007年03月24日 00:00:00 作者:
By shawl.qiu
摘要:
本文演示了ASP服務(wù)端腳本的幾個重要應(yīng)用.
目錄:
1. 遍歷集合/對象
1.1 VBScript 遍歷表單集合
1.2 JScript 遍歷表單集合
2. 轉(zhuǎn)變量值為變量, 并賦值
2.1 VBScript 轉(zhuǎn)變量值為變量并賦值
2.2 JScript 轉(zhuǎn)變量值為變量并賦值
3. 動態(tài)包含文件
3.1 VBScript 動態(tài)包含文件
3.2 JScript 動態(tài)包含文件
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. 轉(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. 動態(tài)包含文件
3.1 VBScript 動態(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 動態(tài)包含文件
linenum
<%
eval($dynInc('aj2.asp'));
Response.Write($test);
function $dynInc($fl){
/* ------------------------------------\
* 服務(wù)端 JScript 動態(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;
}
%>
摘要:
本文演示了ASP服務(wù)端腳本的幾個重要應(yīng)用.
目錄:
1. 遍歷集合/對象
1.1 VBScript 遍歷表單集合
1.2 JScript 遍歷表單集合
2. 轉(zhuǎn)變量值為變量, 并賦值
2.1 VBScript 轉(zhuǎn)變量值為變量并賦值
2.2 JScript 轉(zhuǎn)變量值為變量并賦值
3. 動態(tài)包含文件
3.1 VBScript 動態(tài)包含文件
3.2 JScript 動態(tài)包含文件
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. 轉(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. 動態(tài)包含文件
3.1 VBScript 動態(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 動態(tài)包含文件
linenum
<%
eval($dynInc('aj2.asp'));
Response.Write($test);
function $dynInc($fl){
/* ------------------------------------\
* 服務(wù)端 JScript 動態(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;
}
%>
相關(guān)文章
實例分析之用ASP編程實現(xiàn)網(wǎng)絡(luò)內(nèi)容快速查找的代碼
實例分析之用ASP編程實現(xiàn)網(wǎng)絡(luò)內(nèi)容快速查找的代碼...2007-03-03分享一個好東東,動態(tài)Include文件 (Dynamic File Includes)
相信很多ASP開發(fā)者都會抱怨ASP的Include方式太老土了,以的方式加載文件實在是太不舒服了,在實際項目中不管我是不是一開始就要用到這個文件,我總得早早的把它Include進(jìn)來...這方面PHP就舒服很多...什么時候用,什么時候In...2008-05-05