Link to home
Start Free TrialLog in
Avatar of userTester
userTesterFlag for United States of America

asked on

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
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

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&
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of userTester

ASKER

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]-->