Service-side VBScript and JScript several of the same characteristics

Source: Internet
Author: User
Tags chr eval

1. Traverse the collection/object

1.1 VBScript traverse a collection of forms

LineNum

<%
   for each temp in request.Form
     response.write temp&": "&request.form(temp)
   next
%>

1.2 JScript Traverse Form Collection

LineNum

<%
   for (var $e=new Enumerator(Request.Form); !$e.atEnd(); $e.moveNext()){
     Response.Write($e.item()+':<br/> '+Request.Form($e.item()));
   }
%>

2. The conversion value is variable and assigned

2.1 VBScript Transition measure value is variable and assigned value

LineNum

<%
   for each temp in request.Form
     execute temp&"=request.form(temp)"
   next
%>

2.2 JScript Transition measure value is variable and assign value

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. Dynamic Include files

3.1 VBScript dynamic Include files

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 dynamic Include files

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;
   }
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.