📌  相关文章
📜  XMLHttpRequest() 检查文件是否存在 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:23.393000             🧑  作者: Mango

代码示例1
function UrlExists(url)
{
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
      var http=new XMLHttpRequest();
    } 
    else {
      var http=new ActiveXObject("Microsoft.XMLHTTP");
    }

    http.open('HEAD', url, false);
    http.send();
    return http.status!=404;
}