Results 1 to 1 of 1

Thread: How to work round lack of addEventListener() in IE?

  1. #1
    Join Date
    May 2009

    How to work round lack of addEventListener() in IE?

    What is the best way to write code that binds functions to events on certain elements, when IE doesn't support the addEventListener() method? Is it even worth it to use that method, or is there a better way to code such things?

    Okay, I've been playing around with the code a bit, and instead of using:

      alert("You clicked me!");
    You can just do:

    object.onclick = function(e){
      alert("You clicked me!");
    And that seems to achieve the same effect, but without the incompatibilities, and without as much code too.

    So why exactly would one use addEventListener() then? (I am by no means a Javascript expert, so I am open to being educated )

    Further Edit
    In case anyone is wondering, IE uses attachEvent() instead of addEventListener()
    Last edited by Trillium; 16 Apr 2010 at 02:22 PM. Reason: Some Experimenting

Similar Threads

  1. Acewebsites looking for Web Designers / Developers for ongoing contract work
    By Acewebsites in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 28 Dec 2006, 03:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts