var xmlhttp;
if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();//其他浏览器
}
else if (window.ActiveXObject)
{
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");//旧版IE
}
catch (e) { }
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");//新版IE
}
catch (e) { }
if (!xmlhttp) {
window.alert("不能创建XMLHttpRequest对象");
}
}
yourFileURL="gwjieiee.html"
xmlhttp.open("GET",yourFileURL,false);
xmlhttp.send();
if(xmlhttp.readyState==4){
if(xmlhttp.status==200)
window.location = yourFileURL; //url存在
else
alert("该文件不存在"); //url不存在
}
JavaScript判断文件是否存在
最新推荐文章于 2023-11-12 22:38:55 发布