判断远程图片是否存在

ASP判断远程图片是否存在的代码:

    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来判断远程图片是否存在的代码:

    var oReq = new ActiveXObject(“Microsoft.XMLHTTP“)
    oReq.open(“Get“,“img/weste_net.gif“,false);
    oReq.send();

    if(oReq.status==404)
     alert(’不存在’);
    else
     alert(“存在“)

Copyright ?2005-2008 All rights reserved. www.17zixue8.com 版权所有    赣ICP备07501614号        完美兵团会员待遇说明    站主QQ:335759285