Internet Explorer 9 和 jQuery 2.2.1
Internet Explorer 9 and jQuery 2.2.1
我从 https://dev.windows.com/en-us/microsoft-edge/tools/vms/windows/
下载了一个 IE9 虚拟机
我下载了jQuery2.2.1
jQuery 网站表示支持 Internet Explorer 9。
我做了这个 html 文件。
<html>
<head>
<title>Title</title>
<script src="jquery-2.2.1.js"></script>
</head>
<body>
Hello
</body>
</html>
我在 IE9 中打开此 html 文件,但出现此错误:
SCRIPT438: Object doesn't support property or method 'addEventListener;
jquery-2.2.1.js, line 3578 character 1
这是怎么回事?这是 jQuery 中的错误吗?
What's going on? Is this a bug in jQuery?
您必须设置 doctype
否则您将退回到资源管理器的兼容模式(“怪癖模式”),这将破坏 jQuery 2 因为它本质上是 运行浏览器仅与 Explorer 5.5 一样好(适用于 IE 9 及更早版本)。
Standards mode provides the greatest support for the latest standards, such as HTML5, CSS3, SVG, and others. This is the preferred mode for new public websites.1
...
If Internet Explorer encounters a webpage that doesn't contain a <!DOCTYPE>
element, it opens the page in quirks mode, which can lead to several unexpected side-effects1
...
Windows Internet Explorer 9 and earlier versions, quirks mode restricted the webpage to the features supported by Microsoft Internet Explorer 5.5.1
1参见:https://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx
确保页面以标准模式打开...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge;" />
<title>Title</title>
<script src="jquery-2.2.1.js"></script>
....
我从 https://dev.windows.com/en-us/microsoft-edge/tools/vms/windows/
下载了一个 IE9 虚拟机我下载了jQuery2.2.1 jQuery 网站表示支持 Internet Explorer 9。
我做了这个 html 文件。
<html>
<head>
<title>Title</title>
<script src="jquery-2.2.1.js"></script>
</head>
<body>
Hello
</body>
</html>
我在 IE9 中打开此 html 文件,但出现此错误:
SCRIPT438: Object doesn't support property or method 'addEventListener;
jquery-2.2.1.js, line 3578 character 1
这是怎么回事?这是 jQuery 中的错误吗?
What's going on? Is this a bug in jQuery?
您必须设置 doctype
否则您将退回到资源管理器的兼容模式(“怪癖模式”),这将破坏 jQuery 2 因为它本质上是 运行浏览器仅与 Explorer 5.5 一样好(适用于 IE 9 及更早版本)。
Standards mode provides the greatest support for the latest standards, such as HTML5, CSS3, SVG, and others. This is the preferred mode for new public websites.1
...
If Internet Explorer encounters a webpage that doesn't contain a
<!DOCTYPE>
element, it opens the page in quirks mode, which can lead to several unexpected side-effects1...
Windows Internet Explorer 9 and earlier versions, quirks mode restricted the webpage to the features supported by Microsoft Internet Explorer 5.5.1
1参见:https://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx
确保页面以标准模式打开...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge;" />
<title>Title</title>
<script src="jquery-2.2.1.js"></script>
....