javascript FileReader 和 JSON 对象未在 ie11 中定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20577007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 18:48:31  来源:igfitidea点击:

FileReader and JSON objects not defined in ie11

javascriptjsonfilereaderinternet-explorer-11

提问by andreivu

Whenever trying to open a page running a javascript code using FileReader and JSON upon page initialization, ie11 reports "FileReader is not defined", and later "JSON is not defined". The head of HTML file is as follows:

每当尝试在页面初始化时使用 FileReader 和 JSON 打开运行 javascript 代码的页面时,ie11 报告“未定义 FileReader”,然后报告“未定义 JSON”。HTML文件的头部如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>LogViewer</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" href="css/slick.grid.css" type="text/css"/>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js" type="text/javascript"></script>
</head>

Everything works fine in FF and Chrome. Any ideas?

在 FF 和 Chrome 中一切正常。有任何想法吗?

回答by Jan Schejbal

Add <meta http-equiv="X-UA-Compatible" content="IE=edge" />as the first tag of the header to be sure. IE loves to go to compatibility mode even if a HTML5 doctype is present under certain circumstances (especially on intranet files when the computer is in a domain).

添加<meta http-equiv="X-UA-Compatible" content="IE=edge" />为标题的第一个标签以确保。IE 喜欢进入兼容模式,即使在某些情况下存在 HTML5 文档类型(尤其是当计算机处于域中时,在 Intranet 文件上)。

You can use the developer tools (F12) to check what mode you are running in.

您可以使用开发人员工具 (F12) 检查您正在运行的模式。