Solved

Jquery addEventListener and IE 8

Posted on 2015-02-17
3
483 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
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.

738 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