<%
function GetResStr(URL,code)
err.clear
dim ResBody,ResStr,PageCode,ReturnStr
Set Http=server.createobject("Microsoft.XMLHTTP")
Http.open "GET",URL,False
Http.Send()
If Http.Readystate =4 Then
If Http.status=200 Then
ResBody=http.responseBody
ReturnStr=BytesToBstr(http.responseBody,code)
GetResStr=ReturnStr
End If
End If
End Function
'函数名:BytesToBstr
'作用:转换二进制数据为字符
'参数:Body-二进制数据,Cset-文本编码方式
Function BytesToBstr(Body,Cset)
Dim Objstream
Set Objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset =Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
dim reg,vUrl,VBody,code,time1,time2,title
vUrl="http://fw.qq.com/ipaddress"
TempStr=GetResStr(vUrl,"gb2312")
response.write "您的IP为(asp本地获取):"&request.servervariables("REMOTE_ADDR")&"
"
response.write "您的IP为(ajax获取远程):"&split(TempStr,"""")(1)&" " &split(TempStr,"""")(5)&" "&replace(split(TempStr,"""")(7),"市","")
%>
上面的一段ASP函数的作用是通过[url]http://fw.qq.com/ipaddress[/url]页面的结果 来获得用户的 省份和市
先求一段用AJAX+JS来实现从 [url]http://fw.qq.com/ipaddress[/url] 页面的结果 获取省份和市的(用于静态页面)
也不用ajax,它已经是js的输出了.
//<![CDATA[ alert(IPData[0]); alert(IPData[2]); alert(IPData[3]); //]]>试试看吧