<script>
x = new ActiveXObject("microsoft.XMLHTTP")
x.open("GET","http://info.china.alibaba.com/news/detail/v5-d5714299.html",false)
x.send()
alert(x.responseText)
</script>

解决方案 »

  1.   

    换个地址测试了下<script>
    x = new ActiveXObject("microsoft.XMLHTTP")
    x.open("GET","http://www.52sdn.com/artid/33/33709.html",false)
    x.send()
    alert(x.responseText)
    </script>也是乱码? 对一些大的网站 规范的没有乱码 一些普通的大家自己写的网站10有8,9是乱码
    该怎么解决?
      

  2.   

    大的网站应该是utf8编码的所以没有问题,小的网站是gb2312的。
    我个人是在服务端使用xmlhttp来抓取网页,用vb把乱码解码。
    给你个vb函数
    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
      

  3.   

    我最近也学xmlhttp的东西,孟子E章给出的代码只能在硬盘上访问,放到站点上就不行了吧,因为不能实现跨域访问。
      

  4.   

    BeRush(艾威) vb 可以 但我的环境就支持js 啊