<script type="text/javascript"> function queryAddress(strID){ try{ var qIp=document.getElementById("ip_"+strID); var qUrl='http://ip.wanvee.cn/GetIp.ashx?ipstr='+qIp.firstChild.nodeValue; var ajax=new Ajax.Request(qUrl,{ method:'get', onSuccess:function(strResponse){ var resContent=strResponse.responseText; var strStruct=resContent.substring(resContent.lastIndexOf(",")+1,resContent.length); qIp.innerHTML=strStruct.split(" ")[0]; } }); }catch(e){} } </script>
function queryAddress(strID){ try{ var qIp=document.getElementById("ip_"+strID); var qUrl='queryiplocal.asp?ip='+qIp.firstChild.nodeValue; var ajax=new Ajax.Request(qUrl,{ method:'get', onSuccess:function(strResponse){ qIp.innerHTML=strResponse.responseText; } }); }catch(e){} }
下面的是ASP文件源码:
复制代码 代码如下:
<% Response.ContentType="text/xml" Response.Charset="GB2312" Dim strIP,strPattern strIP=Request.QueryString("ip") strPattern="^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$" If strIP="" Or IsNumeric(strIP) then Response.End() ElseIf Not serRegValidate(strPattern,strIP) then Response.End() End If Dim strURL:strURL="http://www.youdao.com/smartresult-xml/search.s?type=ip&q=" set parser=Server.CreateObject("MSXML2.DOMDocument") parser.async=false parser.ValidateOnParse=true parser.setProperty "ServerHTTPRequest",true parser.load(strURL) if parser.parseError.errorCode<>0 then Response.End() end if set currNode=parser.selectNodes("//product") Dim strLocal:strLocal=currNode.item(0).selectSingleNode("location").text Response.Write Split(strLocal," ")(0) %>