2016-03-15 5 views
2

Я скачал виртуальную машину IE9 из https://dev.windows.com/en-us/microsoft-edge/tools/vms/windows/Internet Explorer 9 и JQuery 2.2.1

Скачал JQuery 2.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> 

открыть этот HTML файл в IE9, и я получаю эту ошибку:

SCRIPT438: Object doesn't support property or method 'addEventListener; 
jquery-2.2.1.js, line 3578 character 1 

Что происходит? Это ошибка в jQuery?

ответ

2

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

См: 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> 
     ....