Solved

Jquery addEventListener and IE 8

Posted on 2015-02-17
3
370 Views
Last Modified: 2015-02-18
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
Comment
Question by:userTester
3 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40615277
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
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 40615315
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
 

Author Closing Comment

by:userTester
ID: 40617256
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now