Home  >  Article  >  Web Front-end  >  用javascript实现检测指定目录是否存在的方法[原创]_javascript技巧

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

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

<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中路径必须是\\来代替
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn