有時(shí),我們想檢測(cè)某個(gè)網(wǎng)址是否存在,或是一個(gè)URL是否存在,可以用下面這個(gè)簡(jiǎn)單代碼實(shí)現(xiàn),asp代碼,簡(jiǎn)單方便
<%
url="http://www.www.yeewaa.com" '也可以使用特定文件如:http://www.yeewaa.com/logo.png
Function chku(murl)
on error resume next
Set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlHttp.open "GET",murl,false
xmlHttp.send
if xmlHttp.Status <> 200 then
chku=false
else
chku=true
end if
End Function
if chku(url) then
response.write(url&"鏈接正常")
else
response.write(url&"鏈接不存在")
end if
%>