Solved

Jquery addEventListener and IE 8

Posted on 2015-02-17
3
392 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

867 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

22 Experts available now in Live!

Get 1:1 Help Now