javascript - JavaScript 在带有 Error-DOM7011 的 IE 11 中不起作用
问题描述
此代码是上传一个csv文件并更改为表格形式。它适用于 chrome 和 safari,但不适用于 IE……我不知道我应该改变什么。我想知道如何解决它。
DOM7011:此页面上的代码禁用了前后缓存。有关详细信息,请参阅:http: //go.microsoft.com/fwlink/ ?LinkID=291337 。
var numQ = 0;
function openCsvFile(){
var input = document.createElement("input");
input.type = "file";
input.accept="text/plain, text/html, .jsp, .csv";
input.click();
input.onchange = function(event){
processFile_csv(event.target.files[0]);
};
}
function processFile_csv(file){
var pass_head = 0;
var reader = new FileReader();
reader.readAsText(file, "UTF-8");
reader.onload = function(){
var allRows = reader.result.split(/\r?\n|\r/);
var table = '<!DOCTYPE html><html lang="ko"><head><meta charset="UTF-8"><meta http-equiv pragma content no-cache ><meta http-equiv="X-UA-Compatible" content="IE=Edge; chrome=1" /><meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Expires" content="0"></head><table id="output" border="1">';
for (var singleRow = 0; singleRow < allRows.length; singleRow++) {
if (singleRow === 0) {
table += '<thead>';
table += '<tr align ="center">';
} else {
table += '<tr align = "center">';
}
var rowCells = allRows[singleRow].split(',');
for (var rowCell = 0; rowCell < rowCells.length; rowCell++) {
if (singleRow === 0) {
table += '<th align = "center">';
table += rowCells[rowCell];
table += '</th>';
} else {
if (rowCells[0] != "") {
table += '<td align = "center">';
if(rowCell == 0){
table += "a";
}
table += rowCells[rowCell];
table += '</td>';
}
}
}
if (singleRow === 0) {
table += '</tr>';
table += '</thead>';
table += '<tbody>';
} else {
table += '</tr>';
}
}
document.getElementById("output").innerHTML = table;
};
}
解决方案
推荐阅读
- android - Android WifiP2pManager 发现 - 无法缩小问题范围
- prolog - prolog中命题逻辑的困难
- c# - 如何将值从文本文件传递到 DataGrid?C#WPF
- python - 如何重命名 csv 文件并在每次循环迭代时更改名称?
- c# - 有什么方法可以从自发光渲染纹理中伪造实时全局照明?
- python - CSV 第一行总是被覆盖(python)
- javascript - Express - 'user' 的所有声明必须具有相同的修饰符
- angular - 如何在断开连接之前清理所有 setInterval
- swift - 在 SceneKit (SwiftUI) 中移动 .dynamic 类型的物理体的最佳方式
- html - 如何从数据库中进入