• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 655
  • Last Modified:

Jquery addEventListener and IE 8

Hi there,

I noticed that when the latest jquery.js file is added to the html page head, IE 8 producers an error:

Object doesn't support property or method 'addEventListener'

I guess this conflicts with any attempt to take into account IE lower than 9. Since the problem is in the jquery.js file, how do I fix this problem?

Thanks
0
userTester
Asked:
userTester
1 Solution
 
COBOLdinosaurCommented:
Ie8 uses the non-standard and obsolete attachEvent() method

It you were using classic javascript it would be a ten minute fix but withjquery I am not sure where you would have to dig into or how many libraries you are working with that might contain the problem.  If you have a list of the events, you could always try adding a script to define the event listeners with attachEvent(), but it would be dodgy.  Part of the price of using something with no recognized standards is that thing just can can without warning.

Cd&
0
 
Rainer JeschorCommented:
Hi,
which exact version of jQuery are you using?
The 2.x branch does not support IE<9 hence you will run into this kind of issues because the supported switches / if statements for handling older IE versions has been removed (which reduced the size).
So if you currently use 2.x then the fix will be to change to 1.11.2
HTH
Rainer
0
 
userTesterAuthor Commented:
Thanks for a clear answer. I decided to use jquery 2.1.3 for IE 9 and above, and version 1.11.2 for IE 8:

<!--[if gt IE 8]>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<![endif]-->

<!--[if lt IE 9]>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<![endif]-->
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now