function CheckURL(byval A_strUrl)
set XMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
XMLHTTP.open "HEAD",A_strUrl,false
XMLHTTP.send()
CheckURL=(XMLHTTP.status=200)
set XMLHTTP = nothing
end function
Dim imgurl
imgurl="img/weste_net.gif"
if CheckURL(imgurl) then
response.write "圖片存在"
else
response.write "圖片不存在"
end if
還有用JavaScript來(lái)判斷遠(yuǎn)程圖片是否存在的代碼:
var oReq = new ActiveXObject("Microsoft.XMLHTTP")
oReq.open("Get","img/weste_net.gif",false);
oReq.send();
if(oReq.status==404)
alert('不存在');
else
alert("存在")