是不是onclick方法中不能用VB的自定义函数?
<script language="vbscript">
function IsExistsFile(up_path)
'判断文件是否已经存在
'up_path文件的名称及路径
uploadfiles=server.MapPath("up\" & up_path)
Set fsys=Server.CreateObject("scripting.FileSystemObject")
path=uploadfiles
set myfile=fsys.getfile(path)
if fsys.fileexists(path) then
IsExistsFile=true
'response.write myfile.size '文件的大小
else
IsExistsFile=false
'response.write "找不到指定文件"
end if
set fsys=nothing
end function
</script>
然后在页面里用下列代码调用,但系统显示isexistsfile未定义。
<input type="submit" value="开始上传" name="B1" class="buttonface " onclick="fvalue=document.myform.f.value;fvalue=fvalue.substring(fvalue.lastIndexOf('\\')+1);return isexistsfile(fvalue);" >
我曾想用JS的自定义函数,但在函数里使用
var fso=new ActiveXobject("scripting.filesystemObject");
就出错。
问题点数:20、回复次数:3Top
1 楼moodboy1982(老鹰)回复于 2006-07-04 17:41:50 得分 10
你的思想错误!
你的函数中的代码全是服务器的代码吧。客户端脚本怎么写上服务器的代码??Top
2 楼moscowljy()回复于 2006-07-04 17:45:38 得分 0
谢谢。Top
3 楼cestar2005(往事随风)回复于 2006-07-04 17:45:41 得分 10
先分清楚客户端和服务器商的概念再来问这个问题
vbscript的代码是在客户端运行的,你里面写的是服务器端运行的代码Top




