欢迎光临
我们一直在努力

那个想用纯JS检测404错误的,来看看.不一定很准确

建站超值云服务器,限时71元/月

<span id=url1></span><br>
<span id=url2></span>
<script language="javascript">
    function butt(){
        tim=1
        setinterval("tim++",100)
        b=1
        autourl1="http://www.dev_club.com/club/bbs/bbsview.asp?boardid=1"
        autourl2="http://www.devclub.com/club/bbs/bbsview.asp?boardid=1"
        url1.innerhtml=" 测试连接:http://www.dev_club.com/club/bbs/bbsview.asp?boardid=1,测试中….. "
        url2.innerhtml=" 测试连接:http://www.devclub.com/club/bbs/bbsview.asp?boardid=1,测试中….. "
    }
    
    function auto(url){
        if(tim>20) {           这个20是关键.20代表2秒.我是假设2秒没反映就认为是连接错误
            document.all(url).innerhtml=" 链接超时 "
        }else{
            document.all(url).innerhtml=" "+tim/10+"秒 "
        }
        b++
    }
    
    function run(){
        document.write("<img src="+autourl1+"/"+math.random()+" width=1 height=1 onerror=auto(url1)>")
        document.write("<img src="+autourl2+"/"+math.random()+" width=1 height=1 onerror=auto(url2)>")
    }

    butt()
    run()
</script>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 那个想用纯JS检测404错误的,来看看.不一定很准确
分享到: 更多 (0)

相关推荐

  • 暂无文章