有時,我們想檢測某個網址是否存在,或是一個URL是否存在,可以用下面這個簡單代碼實現,asp代碼,簡單方便
<%
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
%>