对iis写权限的利用 >>
<< 用XMLHTTP Post/Get HTML页面时的中文乱码之完全Script解决方案
2 Steps to use encoding on XMLHttp

Author Zhou Renjian Create@ 2004-10-16 16:00 Modified@ 2004-10-16 16:01
whizz Note icon

Saving the following codes in a file "encoding.vbs":

Function URLEncoding(vstrIn)
    strReturn = ""
    For i = 1 To Len(vstrIn)
        ThisChr = Mid(vStrIn,i,1)
        If Abs(Asc(ThisChr)) < &HFF Then
            strReturn = strReturn & ThisChr
        Else
            innerCode = Asc(ThisChr)
            If innerCode < 0 Then
                innerCode = innerCode + &H10000
            End If
            Hight8 = (innerCode  And &HFF00)\ &HFF
            Low8 = innerCode And &HFF
            strReturn = strReturn & "%" & Hex(Hight8) &  "%" & Hex(Low8)
        End If
    Next
    URLEncoding = strReturn
End Function

Function bytes2BSTR(vIn)
    strReturn = ""
    For i = 1 To LenB(vIn)
        ThisCharCode = AscB(MidB(vIn,i,1))
        If ThisCharCode < &H80 Then
            strReturn = strReturn & Chr(ThisCharCode)
        Else
            NextCharCode = AscB(MidB(vIn,i+1,1))
            strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
            i = i + 1
        End If
    Next
    bytes2BSTR = strReturn
End Function

and use the following codes to load responseBody:

 <script type="text/vbscript" src="encoding.vbs"></script>
 <script type="text/javascript">
  var uri = http://www.whizzideas.com/";
     var xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  xmlHttp.open("GET", uri, false);
     xmlHttp.send(null);
     //alert(ASCIIs2GB2312s(xmlHttp.responseBody));
     document.getElementById("inner").innerText = bytes2BSTR(xmlHttp.responseBody);
 </script>

本记录所在类别:
本记录相关记录: