朋友们,帮个忙。帮我将以下VBSCRIPT代码,转成JSCRIPT的,谢谢。在线等待~~=======================================
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 FunctionFunction Query()
 dim XmlHttp
 set XmlHttp = CreateObject("Microsoft.XMLHTTP")
 XmlHttp.Open "GET", "userregchk.asp?strRegName="+strRegName.value, false 
 XmlHttp.setRequestHeader "Content-Type","text/XML" 
 XmlHttp.Send
 
 dim html 
 html = bytes2BSTR(XmlHttp.responseBody)
 msg1.innerText = html
End Function

解决方案 »

  1.   

    var html;function bytes2BSTR(str){
    var ret = '', l = lenB(str);
    for (var code, i = 0; i < l; i++) {
    code = str.charCodeAt(i);
    if (code < 0x80) {
    ret += String.fromCharCode(code);
    } else {
    ret += String.fromCharCode(code * 0x100 + str.charCodeAt(i + 1));
    }
    }
    return ret;
    }function creatXHR(){
    if (window.ActiveXObject) return new window.ActiveXObject('Microsoft.XMLHTTP');
    else if (window.XMLHttpRequest) return new window.XMLHttpRequest();
    else return null;
    }function Query(){
    var xmlHttp = creatXHR();
    xmlHttp.open('GET', 'userregchk.asp?strRegName=' + strRegName.value, false);
    xmlHttp.setRequestHeader('Content-Type', 'text/xml');
    xmlHttp.onreadystatechange = function(){
    if (xhr.readyState == 4 && xhr.status == 200) {
    msg1.innerText = html = bytes2BSTR(xmlHttp.responseText);
    }
    }
    xmlHttp.send(null);
    }function lenB(str){
    for (var code, len = i = 0; i < str.length; i++) {
    code = str.charCodeAt(i);
    if (code < 0x007f) {
    len += len + 1;
    } else if ((0x0080 <= code) && (code <= 0x07ff)) {
    len += 2;
    } else if ((0x0800 <= code) && (code <= 0xffff)) {
    len += 3;
    }
    }
    return len;
    }