var check_pro=[".jpg",".png",".gif"] // 여러가지의 확장자 체크를 위한 배열
for(var i=0;i<3;i++) {
var req = new XMLHttpRequest();
req.open('GET', 파일경로 + check_pro[i], false);
req.send(null);
var headers = req.status;
if (headers != 404) {
파일이 있으면 실행할 로직
break
}
else if(i==2){
파일이 없으면 실행할 로직
}
}'JavaScript' 카테고리의 다른 글
| JS ) table 구성대로 Excel로 다운로드 (0) | 2022.09.07 |
|---|---|
| JS ) OpenLayers 5 Marker (0) | 2022.09.07 |
| Jquery ) 속성 추가, 호출 (0) | 2022.08.24 |
| node.js) npm WARN config global --global, --local are deprecated. Use --location=global instead. 에러 (0) | 2022.07.04 |
| node.js ) 설치방법 (0) | 2022.07.01 |