我的一亩三分地 我就喜欢!
13fen  设为主页
 收藏本站
 
当前位置: > 一亩三分地:首页 > 操作系统 > 服务器 > 服务端 VBScript 与 JScript 几个相同特性的写法
热门文章排行
热门文章排行 启动与关闭服务器(12-28)
服务器应用:用serv-u建立FTP一(11-16)
破解局域网内不能互访的六大经典问题(12-28)
Windows中IIS内FTP服务器高级配置(11-16)
怎样设置域名的DNS服务器(11-16)
精采文章排行
精采文章排行 在Windows Server 2003中为Web站点(11-16)
IP基础--DNS协定(11-16)
怎样设置域名的DNS服务器(11-16)
DNS—bind安装与配置的关键技术揭秘(11-16)
Exchange Server 服务器通讯端口(11-16)
技术专题推荐
网管论坛交流
 

服务端 VBScript 与 JScript 几个相同特性的写法 

作者:   来源:   点击:   日期:2006-10-16

1. 遍历集合/对象
1.1 VBScript 遍历表单集合
    linenum
  1. <%
  2.     for each temp in request.Form
  3.         response.write temp&": "&request.form(temp)
  4.     next
  5. %>

1.2 JScript 遍历表单集合
    linenum
  1. <%
  2.     for (var $e=new Enumerator(Request.Form); !$e.atEnd(); $e.moveNext()){
  3.         Response.Write($e.item()+':<br/> '+Request.Form($e.item()));
  4.     }
  5. %>

2. 转变量值为变量, 并赋值
2.1 VBScript 转变量值为变量并赋值
    linenum
  1. <%
  2.     for each temp in request.Form
  3.         execute temp&"=request.form(temp)"
  4.     next
  5. %>

2.2 JScript 转变量值为变量并赋值
    linenum
  1. <%
  2.     var $xml=new ActiveXObject("microsoft.xmldom");
  3.         $xml.load(Server.MapPath('config.xml'));
  4.         var $childNodes=$xml.documentElement.selectSingleNode('//siteconfig').childNodes
  5.         
  6.         for ($e=new Enumerator($childNodes); !$e.atEnd(); $e.moveNext()){
  7.             eval($e.item().nodeName+"=$e.item().text");
  8.         }
  9.     $xml=null;
  10.         Response.Write(sitekeywords);
  11. %>

3. 动态包含文件
3.1 VBScript 动态包含文件
    linenum
  1. <%
  2.   function fInclude(filepath)
  3.   ' sample call '''/// execute fInclude("include/system/language/"&sitefglang&"/main.asp") \\\'''
  4.       dim cnt
  5.           cnt=CreateObject("scripting.fileSystemObject").openTextFile(server.MapPath(filepath)).readall
  6.           cnt=replace(cnt,"<"&chr(37),"")
  7.           cnt=replace(cnt,chr(37)&">","")
  8.           fInclude=cnt
  9.   end function 'shawl.qiu code'
  10.     execute fInclude("include/system/language/"&sitefglang&"/main.asp")
  11. %>

3.2 JScript 动态包含文件
    linenum
  1. <%
  2.     eval($dynInc('aj2.asp'));
  3.     Response.Write($test);
  4.     
  5.     function $dynInc($fl){
  6.     /* ------------------------------------\
  7.     * 服务端 JScript 动态包含文件 By l.qiu
  8.     * sample call: eval($dynInc('aj2.asp')); 
  9.     \*------------------------------------*/
  10.         var $fso=new ActiveXObject("scripting.fileSystemObject");
  11.             $str=$fso.OpenTextFile(Server.MapPath($fl)).ReadAll();
  12.             $str=$str.replace(/\<\%|\%\>/g,'');
  13.         $fso=null;
  14.         return $str;
  15.     }
  16. %>



文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【论坛讨论

   相关文章:
·Excel快速导入文本文件技巧 ·将整个网页保存在一个文件中
·技巧:如何用好地址栏的IE图标 ·屏蔽恶意网站的一种技巧
·释放C盘空间的15招 ·忘记Foxmail密码的七种解决办法!

   文章评论:(条)
  
 请留名: 匿名评论   点击查看所有评论 网管论坛
 

  责任编辑:一分  声明:刊登此文章是为了传递更多信息,文章内容仅供参考,转载请注明出处。