0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JavaScript で、画像ファイル群が存在するかちぇくプログラム。

Posted at

苦労してやっとできた。

/*  定義  */
let faile_ch_li = "";
var aru_arr = ['imge/cyat.png','imge/gall_1.png','imge/gall.png','imge/H_na_gazou.jpg','imge/man1.png',];
aru_arr.push('imge/んんん.png');//'imge/んんん.png' fileは確実に存在する名前付けの最後のファイル名でソートの最後のファイル名
var aru_arr2 = aru_arr;
faile_check();
/* faile_check */
function faile_check(){
    alert('faile_check');
    count_n = 0;
    for(let i = 0; i < aru_arr.length; i++){
        checkFileExists(aru_arr[i]);
    }
}
/* checkFileExists */
function checkFileExists(url) {
    var path_f = url;
    var element_f = new Image();
    element_f.onload = function () {        
        var width_f = element_f.naturalWidth;
        var height_f = element_f.naturalHeight;
        for(let i = 0; i < aru_arr.length; i++){
            if(aru_arr2[i] == path_f){
                aru_arr2.splice(i, 1);
            }
        }
        faile_ch_li=width_f + ' * ' + height_f;//使わない変数を処理して置く
       // if(!path_f){faile_ch_li="問題が解決見つかりました。";}else{faile_ch_li="問題なし。";}
       // alert(faile_ch_li +aru_arr2.length+ ' * ' + path_f + ' * ' + width_f + ' * ' + height_f);
        if(path_f == 'imge/んんん.png'){
            if(aru_arr2.length == 0){
                alert('全てのファイルが存在します。');
            }else{
                faile_ch_li=aru_arr2.join('\n');
                alert('無いのは '+aru_arr2);
            }
        }        
     };    
    element_f.src = path_f;     
}

スクリーンショット 2024-04-28 155256.png

参考にどうぞ。

0
0
11

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?