Add readAsBinaryString function to IE11

This commit is contained in:
Ilker Kulgu 2017-07-13 15:14:55 +02:00 committed by Luc Didry
parent c6cdf2354f
commit 6889b0eccc
1 changed files with 26 additions and 0 deletions

View File

@ -22,6 +22,32 @@
console.log(i18n.confirmExit);
return i18n.confirmExit;
}
// Is the browser IE?
var isIE = /*@cc_on!@*/false || !!document.documentMode;
// If the browser is IE, add readAsBinaryString function and store the data
if (isIE == true){
if (FileReader.prototype.readAsBinaryString === undefined) {
FileReader.prototype.readAsBinaryString = function (fileData) {
var binary = "";
var pt = this;
var reader = new FileReader();
reader.onload = function (e) {
var bytes = new Uint8Array(reader.result);
var length = bytes.byteLength;
for (var i = 0; i < length; i++) {
binary += String.fromCharCode(bytes[i]);
}
//pt.result - readonly so assign content to another property
pt.content = binary;
$(pt).trigger('onloadend');
}
reader.readAsArrayBuffer(fileData);
}
}
}
% end
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>