DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> 如何使用JS獲取IE上傳文件路徑(IE7,8)
如何使用JS獲取IE上傳文件路徑(IE7,8)
編輯:關於JavaScript     
本篇文章是對使用JS獲取IE上傳文件路徑的實現代碼進行了詳細的分析介紹,需要的朋友參考下   復制代碼 代碼如下:


function validateFileSize(id, maxsize) {
            var btnsave = document.getElementById("Button2");
            btnsave.disabled = false;
            var filepath = "";
            var fileupload = document.getElementById(id);
            if (fileupload.value.length < 5) { alert('請選擇文件!'); return; }
            var agent = window.navigator.userAgent;
            if (document.all) {
                var isIE7 = agent.indexOf('MSIE 7.0') != -1;
                var isIE8 = agent.indexOf('MSIE 8.0') != -1;
                //IE7和IE8獲得文件路徑
                if (isIE7 || isIE8) {
                    fileupload.select();
                    filepath = document.selection.createRange().text;
                }
                //IE6獲得文件路徑
                else
                { filepath = file.value; }
                //PageMethods.ValidateFile(filepath, maxsize, ieCallBack);
                alert(filepath);
            }
            if (agent.indexOf("Firefox") >= 1) {
                alert("FF");
                alert(getValue());
                return false;
                if (fileupload.files) {
                    var size = fileupload.files[0].fileSize;
                    if (size > parseInt(maxsize)) {
                        fileupload.parentNode.innerHTML = '<input type="file" name="' + fileupload.name + '" id="' + fileupload.id + '" onchange="disableSave(this);"/> ';
                        alert("文件超過大小!");
                    }
                    else { alert("文件上傳成功!"); }
                }
            }
        }

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved