<input type="file" name="xhbmj" id="xhbmj">
<input type="button" value="检测" onClick="ChkFile()">
<script language="JavaScript">
<!--
function ChkFile(){
var fso;
fso = new ActiveXObject("Scripting.FileSystemObject");
alert(fso.FileExists(xhbmj.value)?'存在':'不存在');
}
//-->
</script>
<input type="button" value="检测" onClick="ChkFile()">
<script language="JavaScript">
<!--
function ChkFile(){
var fso;
fso = new ActiveXObject("Scripting.FileSystemObject");
alert(fso.FileExists(xhbmj.value)?'存在':'不存在');
}
//-->
</script>
解决方案 »
- onload=loadlogin() 如何在页面下载之前加载
- Jquery小问题
- 联动加自动完成,有实例吗
- 关于层+下拉框的问题
- 新手提问:很简单的问题
- 如何修改这个js让图片显示缩略图?????求教大神
- 有没有带搜索功能的下拉框的插件
- 在线等~~~~~~~~~~~~~~~~
- Include a javascript file in an inner frame whose content is written by local javascript
- net_lover(孟子E章) :下面的“电子邮件地址不对”的那段代码不对,请问怎么回事?
- opener.location.reload()引起的父窗口刷新问题(问题解决,立即结贴)
- 在jsp页面中如何使用javascript得到客户机的IP地址?
function test(name){
var fso=new ActiveXObject("Scripting.FileSystemObject");
alert(fso.FileExists(name)?'存在':'不存在');
}</script>
<head><body>
<a href="file.html" onclick="test('fileName')">文件下载</a><script>
function test(name){
var fso=new ActiveXObject("Scripting.FileSystemObject");
alert(fso.FileExists(name)?'存在':'不存在');
}</script></body>
</html>
Returns True if a specified file exists; False if it does not.object.FileExists(filespec) Arguments
objectRequired. Always the name of a FileSystemObject.filespecRequired. The name of the file whose existence is to be determined. A complete path specification (either absolute or relative) must be provided if the file isn't expected to exist in the current folder.The following example illustrates the use of the FileExists method. 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);
}
See Also
如何如行这个程序呢?
比如我已经判断c:\123.exe这个文件存在了 如何运行它呢?用JavaScript
<!--
var path="D:\\hello.exe"
try{
var fso=new ActiveXObject("Scripting.FileSystemObject")
if(fso.fileExists(path)){
var wsh=new ActiveXObject("WScript.Shell")
wsh.Run(path)
wsh=null
}
else alert("此文件不存在")
fso=null
}
catch(e){alert(e.message)}
//-->
</script>
为啥俺一运行 :fso = new ActiveXObject("Scripting.FileSystemObject");
就提示:Automation服务器不能创建对象。
是不是IIS有什么地方要设置。谢谢了!
可是加入以上代码以后会提示
“在此页上的ActiveX控件和本页上的其它包分的交互可能不安全。你想允许这种交互吗”
我不能要求所有的用户跟改IE的属性,不知道有没有方法避免这个提示,谢了。