用JAVASCIPT判断文件是否存在?在线等待,参与者都有分!!!

xiaobeibei 2002-10-18 12:48:41
怎么用JAVASCRIPT判断一个文件是否存在.
注意我不想用FileSystemObject,因为它还需要调整安全权限.
如果用了它以后能不用安全权限就能判断一个文件是否存在也可以.
...全文
31 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaobeibei 2002-10-18
  • 打赏
  • 举报
回复
哎,还是我自己找到的,可惜不能给自己加分.
楼上的,给你们分吧.
<html>
<head>
<script language="javascript">
<!--
var fileExists = false;
function yes()
{
alert("the file exists.");
yes = true;
}

function no()
{
if(!fileExists)
{
alert("the file does not exist.");
}
}

window.onerror = yes
window.onload = no
//-->
</script>
<script language="javascript"
src="file://c:\autoexec.bat"></script>
</head>
</html>
wind0209 2002-10-18
  • 打赏
  • 举报
回复
想不出来。
lbd8848 2002-10-18
  • 打赏
  • 举报
回复
好像除了FileSystemObject,没有其他方法了吧
lbd8848 2002-10-18
  • 打赏
  • 举报
回复
没看清,原来你不想使用FileSystemObject
lbd8848 2002-10-18
  • 打赏
  • 举报
回复
function ReportFileStatus(filespec)
{
var fso, s = filespec;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(filespec))
s += " exists.";
else
s += " doesn't exist.";
return(s);
}

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧