Reputation: 1286
I downloaded an IE9 virtual machine from https://dev.windows.com/en-us/microsoft-edge/tools/vms/windows/
I downloaded jQuery 2.2.1 The jQuery website says Internet Explorer 9 is supported.
I made this html file.
<html>
<head>
<title>Title</title>
<script src="jquery-2.2.1.js"></script>
</head>
<body>
Hello
</body>
</html>
I open this html file in IE9 and I get this error:
SCRIPT438: Object doesn't support property or method 'addEventListener;
jquery-2.2.1.js, line 3578 character 1
What's going on? Is this a bug in jQuery?
Upvotes: 2
Views: 1988
Reputation: 98718
What's going on? Is this a bug in jQuery?
You must set a doctype
or you'll fall back into Explorer's compatibility mode ("quirks mode"), which will break jQuery 2 since it's essentially running in a browser only as good as Explorer 5.5 (applicable to IE 9 and earlier).
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
1See: https://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx
Ensure the page opens in standards mode...
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge;" />
<title>Title</title>
<script src="jquery-2.2.1.js"></script>
....
Upvotes: 2