function checkURL(URL) { var xmlHttp; if (window.ActiveXObject){ //xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlHttp=new ActiveXObject("MSXML2.XMLHTTP"); }else{ xmlHttp=new XMLHttpRequest(); } xmlhttp.abort(); xmlhttp.open("GET",URL,false); xmlhttp.send(); if (xmlhttp.readyState==4) { if (xmlhttp.status==200) return true; //成功 else if (xmlhttp.status==404) return false; // 没有找到 else if (xmlhttp.status==500) return false; // 服务器错误 else return false; } }
用JavaScript检查文件是否存在
最新推荐文章于 2021-05-08 21:47:15 发布