FileInput在IE11中不起作用

时间:2017-11-28 07:45:27

标签: javascript jquery

我有以下代码打开一个窗口对话框,以docx,doc,txt格式浏览文档,并且在chrome的情况下工作正常,但在IE11中无法加载上传的文档。我尝试用一​​种不起作用的形式包装输入。如何在IE11中使其工作?

 function OpenImportDialogue() {        
        $("#fileinput").click();
        }
 $("#fileinput").change(function() {       
        readDocument(this);
    });
   function readDocument(input) {

        if (input.files && input.files[0]) {
            var fileReader = new FileReader();
            fileReader.onload = function(e) {
                var streamType = TXTextControl.streamType.PlainText;
                // set the StreamType based on the lower case extension
                switch (input.value.split('.').pop().toLowerCase()) {
                    case 'doc':
                        streamType = TXTextControl.streamType.MSWord;
                        break;
                    case 'docx':
                        streamType = TXTextControl.streamType.WordprocessingML;
                        break;
                    case 'rtf':
                        streamType = TXTextControl.streamType.RichTextFormat;
                        break;
                    case 'txt':
                        streamType = TXTextControl.streamType.PlainText;
                        break;
                    default:
                        alert("doc, docx, txt and rtf are the supported document Types");

                }
                // load the document beginning at the Base64 data (split at comma)
                var lines =  e.target.result.split(',')[0];
                if(lines.includes('base64'))
                    TXTextControl.loadDocument(streamType, e.target.result.split(',')[1]);
                else
                    TXTextControl.Load(streamType,  "IA==");
                $(input).prop("value", "");
            };
            // read the file and convert it to Base64
            fileReader.readAsDataURL(input.files[0]);
        }
    }
<div class='ribbon-button ribbon-button-big' onclick='OpenImportDialogue()' >

谢谢

0 个答案:

没有答案