简体   繁体   中英

Reading user parameter file in IE8 with Javascript

OK folks - all suggestions gratefully accepted. I am a relative novice hitting head against hard brick wall.

Basically what I am doing is reading a user parameter file to produce multiple reports. I have this working perfectly in Firefox using the AddEventListener and FileReader functions. IE8 does not allow me to do this -I have tried AttachEvent (see MSIE and addEventListener Problem in Javascript? ) which will list the files but does not allow me to read the user selected one. (Why Microsoft considers this a security exposure and Mozilla do not perplexes me.)

I do not want the user to have to input all the data into a form as I want the data to be re-usable ie I envisage users making small changes to a small selection of parameters every so often and re-running.

Apart from doing a check for IEx and telling them to use another browser, is there another method anyone would recommend?

Thanks in anticipation

Hi basically I have a flat parameter file that I want to read from users computer (in specified format) that will then produce reports. Necessity being the mother of invention I have come up with an alternative solution to reading the file. That is to copy the file contents into a text area and then use to process it

<textarea id="myTextarea" cols="45" rows="20">Copy in here</textarea>

<br />
<button type="button" onclick="readParameters()">then click here</button>
<script>
function readParameters()
{contents=document.getElementById("myTextarea").value;}
</script>

Not as neat as selecting a file but at least it works with IE

User1446214 has got the right idea, I've added a compatibility check by using and if statement and put the text area in a JQuery dialog box if the file reader fails:

if (window.File && window.FileReader && window.FileList && window.Blob) {
// load file code
} else {
//open jquery dialog box with text area
$("#fileInputDialog").dialog("open");

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM