<script language="javascript"> function baoGetHTML(url, divTarget) { var oHttp = new ActiveXObject("Microsoft.XMLHTTP"); oHttp.open("GET", url, false); oHttp.send(); bao.value = bytes2BSTR(oHttp.responseBody); } </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> <input type=button onclick="baoGetHTML('http://community.csdn.net/Expert/style/get_css.js')" value="Get"> <input type=text id=bao> </BODY> </HTML>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<script language="javascript">
function baoGetHTML(url, divTarget)
{
var oHttp = new ActiveXObject("Microsoft.XMLHTTP");
oHttp.open("GET", url, false);
oHttp.send();
bao.value = bytes2BSTR(oHttp.responseBody);
}
</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>
<input type=button onclick="baoGetHTML('http://community.csdn.net/Expert/style/get_css.js')" value="Get">
<input type=text id=bao>
</BODY>
</HTML>
提示我没有权限呀,我试过多次了,不能用,XMLHTTP在服务器端脚本中还行,在客户端脚本中不管用。
这个问题也只能在服务器端去取了。
你可以在服务器端写一个取的页面,然后再客户端向这个取数据的页面传递被取的目标链接,然后再得到返回的 responseText。