Truly
写精彩代码 品暇逸人生

<HTML><HEAD>
<SCRIPT>

function getFileSize (fileName) {

if (document.all) {
window.oldOnError = window.onerror;    
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('没有访问文件的权限');        
return true;      
}     
else
return false;    
};
    var fso = new ActiveXObject('Scripting.FileSystemObject');
    var file = fso.GetFile(fileName);    
window.onerror = window.oldOnError;
    return file.Size;  }}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="formName"><INPUT TYPE="file" NAME="fileName"><BR>
<INPUT TYPE="button" VALUE="查看文件字节大小" ONCLICK="alert(getFileSize(this.form.fileName.value)+'字节')"><BR>
</FORM></BODY>
</HTML>

posted on 2006-04-11 15:26  Truly  阅读(327)  评论(0编辑  收藏  举报