Function viewSource1()
dim XmlHttp
set XmlHttp = CreateObject("Microsoft.XMLHTTP")
XmlHttp.Open "GET", document.location.href, false
XmlHttp.setRequestHeader "Content-Type","text/XML"
XmlHttp.Send
dim html
html = bytes2BSTR(XmlHttp.responseBody)
msgbox html
End Function
Function viewSource2()
dim XmlHttp
set XmlHttp = CreateObject("Microsoft.XMLHTTP")
XmlHttp.Open "GET", "http://www.google.com", false
XmlHttp.setRequestHeader "Content-Type","text/XML"
XmlHttp.Send
dim html
html = bytes2BSTR(XmlHttp.responseBody)
msgbox html
End Function
</script>
<BODY bgcolor=gainsboro style='border:1pt solid white'>
<TABLE class=text>
<tr>
<td class=text>XMLHTTP Get HTML页面时的中文乱码之完全客户端Script解决方案</td>
</tr>
<tr>
<td class=button><button onclick=viewSource1()>查看自身的网页代码</button></td>
</tr>
<tr>
<td class=button><button onclick=viewSource2()>查看google主页代码</button></td>
</tr>
</TABLE>
</BODY>
</HTML>