<script>
<!--
function getXML(URL) {
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("GET",URL, false);
xmlhttp.Send("");
var result = bytes2BSTR(xmlhttp.responseBody);
return result;
}
//-->
</script><script language="vbscript">
Function bytes2BSTR(vIn) Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
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
</script><button onclick=alert(getXML("http://www.5inet.net/article/xml/1024.xml"))>获取xml</button>
<!--
function getXML(URL) {
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("GET",URL, false);
xmlhttp.Send("");
var result = bytes2BSTR(xmlhttp.responseBody);
return result;
}
//-->
</script><script language="vbscript">
Function bytes2BSTR(vIn) Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
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
</script><button onclick=alert(getXML("http://www.5inet.net/article/xml/1024.xml"))>获取xml</button>
不行呀,不用那个转换函数还可以显示alert一大堆,用了以后只剩下"<"一个字符了
输出前用
<?
header("content-type","text/html; charset=gb2312");
?>
就是这种乱麻。各位分析大概是什么原因造成的
就是这种乱麻。各位分析大概是什么原因造成的
alert(bytes2BSTR(XH.responseBody));
既要用到轉換函數,也要用到responseBody請問一下這裡responseBody和responseText爲什麽會不同?