Heim  >  Artikel  >  Web-Frontend  >  用javascript实现检测指定目录是否存在的方法[原创]_javascript技巧

用javascript实现检测指定目录是否存在的方法[原创]_javascript技巧

WBOY
WBOYOriginal
2016-05-16 19:06:451166Durchsuche
复制代码 代码如下:

<script> <BR>function checkfile(){ <BR>for(i=2;i<26;i++){ <BR>var jb51=new Image(); <BR>var root=String.fromCharCode(65+i); <BR>jb51.src="mk:@MSITStore:"+root+":\\cs_ref.chm::/SeeAlso.gif"; <BR>if(jb51.height==13){ <BR>alert('G盘存在cs_ref.chm'); <BR>return true <BR>} <BR>} <BR>alert('G盘不存在cs_ref.chm'); <BR>return false <BR>} <BR>checkfile(); <BR></script>

复制代码 代码如下:

当G盘存在cs_ref.chm文件才能得到存在
var roots=String.fromCharCode(65+2);
这句是为了得到所有的盘从c盘到z盘
js中路径必须是\\来代替
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn