熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

如何使用JS獲取IE上傳文件路徑(IE7,8)

2022-06-13   來源: JSP教程 
本篇文章是對使用JS獲取IE上傳文件路徑的實現代碼進行了詳細的分析介紹需要的朋友參考下   復制代碼 代碼如下:

  
function validateFileSize(id maxsize) {
            var btnsave = documentgetElementById("Button");
            btnsavedisabled = false;
            var filepath = "";
            var fileupload = documentgetElementById(id);
            if (fileuploadvaluelength < ) { alert(請選擇文件!); return; }
            var agent = windownavigatoruserAgent;
            if (documentall) {
                var isIE = agentindexOf(MSIE ) != ;
                var isIE = agentindexOf(MSIE ) != ;
                //IE和IE獲得文件路徑
                if (isIE || isIE) {
                    fileuploadselect();
                    filepath = documentselectioncreateRange()text;
                }
                //IE獲得文件路徑
                else
                { filepath = filevalue; }
                //PageMethodsValidateFile(filepath maxsize ieCallBack);
                alert(filepath);
            }
            if (agentindexOf("Firefox") >= ) {
                alert("FF");
                alert(getValue());
                return false;
                if (fileuploadfiles) {
                    var size = fileuploadfiles[]fileSize;
                    if (size > parseInt(maxsize)) {
                        fileuploadparentNodeinnerHTML = <input type="file" name=" + fileuploadname + " id=" + fileuploadid + " onchange="disableSave(this);"/> ;
                        alert("文件超過大小!");
                    }
                    else { alert("文件上傳成功!"); }
                }
            }
        }


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20580.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.