<head>
<title>利用xmlhttp检测url及探测服务器信息</title>
<meta name="generator" content="editplus">
<meta name="author" content="jnkc">
<meta name="keywords" content="">
</head>
<body>
请输入url:<input type="text" id="jnkcinput" value="http://" size="40"><button id="chk">检测</button>
<div id="jnkc_show"></div>
<script language="vbscript">
dim i,jnkcurl,jnkchtml,jnkcstatus,jnkcserver
function chk_onclick()
jnkcurl = jnkcinput.value
call getdetail
i = i+1
jnkc_show.innerhtml = "<hr><pre><font color=red>" & i & "、" & jnkcurl & "</font><br>" & jnkcstatus & "</pre>" & jnkc_show.innerhtml
end function
dim jnkcxmlhttp
sub getdetail
set jnkcxmlhttp = createobject("microsoft.xmlhttp")
jnkcxmlhttp.onreadystatechange = getref("getstatus")
jnkcxmlhttp.open "get", jnkcurl, false
on error resume next
jnkcxmlhttp.send
set jnkcxmlhttp = nothing
end sub
sub getstatus
if jnkcxmlhttp.readystate <> 4 then
exit sub
end if
if jnkcxmlhttp.status = 404 then
jnkcstatus = "该网页不存在!"
elseif jnkcxmlhttp.status < 200 then
jnkcstatus = "客户端错误,信息:" & cstr(jnkcxmlhttp.status) & " " & jnkcxmlhttp.statustext
elseif jnkcxmlhttp.status < 300 then
jnkcstatus = "成功,该网页能访问。"
elseif jnkcxmlhttp.status < 400 then
jnkcstatus = "重定向,信息:" & cstr(jnkcxmlhttp.status) & " " & jnkcxmlhttp.statustext
elseif jnkcxmlhttp.status < 500 then
jnkcstatus = "客户端错误,信息:" & cstr(jnkcxmlhttp.status) & " " & jnkcxmlhttp.statustext
elseif jnkcxmlhttp.status < 600 then
jnkcstatus = "服务器错误,信息:" & cstr(jnkcxmlhttp.status) & " " & jnkcxmlhttp.statustext
else
jnkcstatus = "域名不可用或网络连接错误,信息:" & cstr(jnkcxmlhttp.status) & " " & jnkcxmlhttp.statustext
end if
if jnkcxmlhttp.status < 600 then call getserver
end sub
sub getserver
jnkcserver = jnkcxmlhttp.getresponseheader("server")
if jnkcserver <> "" then
jnkcstatus = jnkcstatus & "<br>http服务器:" & jnkcserver
end if
jnkcstatus = "<b>" & jnkcstatus & "</b><br>所有反馈信息:<br>"& jnkcxmlhttp.getallresponseheaders
end sub
</script>
</body>
</html>
文章整理:站长天空 网址:http://www.z6688.com/
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




