<script language=”javascript”>
function xmlHTTP() {
var x = new ActiveXObject(“Microsoft.XMLHTTP”)
x.open(“get”,”http://www.sample.com/page.htm”,false);
x.send();
var strv = x.responseBody;
document.all.xmlhttpBody.innerHTML = BinDecode(strv);
}
</script>
<script language=”vbscript”>
‘—————————————–
‘ BinDecode (바이너리 -> 아스키 변환)
‘ mongmong – 2003. 2
‘—————————————–
Public Function BinDecode(byVal binData)
Dim i, byteChr, strV
For i = 1 to LenB(binData)
byteChr = AscB(MidB(binData,i,2))
If byteChr > 127 Then
i = i + 1
strV = strV & Chr(“&H” & Hex(byteChr) & Hex(AscB(MidB(binData,i,2))))
Else
strV = strV & Chr(byteChr)
End if
Next
BinDecode = strV
End Function
</script>
<div id=xmlhttpBody></div>
var strv = x.responseText; 을 사용하면
HTML소스를 긁어올수 있으나 한글문자에서 깨져버리는군요.
그래서 위 소스에선 var strv = x.responseBody;을 사용하여 바이너리 형태로 데이타를 가져와서 BinDecode() 라는 vbScript를 만들어 바이너리를 아스키로 변환해서 출력해 주네요.