Problems with addEvent in IE7

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm doing an image slide show on a web site:

I use a tool called smooth gallery ( /
showcase/manual-slideshow/) that uses Mootools itself.

However, I don't want the arrows inside the image box, I want the user
to be able to click on arrows that are pictures outside the box.

The code that handles the click on the original version is as follow:

        if ((this.galleryData.length>1)&&(this.options.showArrows))
            var leftArrow = new Element('a').addClass('left').addEvent(
            var rightArrow = new Element('a').addClass('right').addEvent(

I changed the code to this:

        if ((this.galleryData.length>1)&&(this.options.showArrows))
            var leftArrow = document.getElementById("flgauche").addEvent(
            var rightArrow = document.getElementById("fldroit").addEvent(

Basically, I removed a call to the injectInside method that puts the
arrows inside the box and I used the same addEvent method but with my
already existing objects (flgauche and fldroit). It works fine in
Firefox, but doesn't work in IE6 nor 7. It tells me that the object
doesn't support the method.

My thinking is that the value of document.getElementById("flgauche")
doesn't support the addEvent method, but I'm puzzled as to how to do
it so it works fine.

Thanks in advance

Re: Problems with addEvent in IE7 wrote:
Quoted text here. Click to load it

Two points - first: although a lot of people here know javascript, you
would be better off asking a javascript question in
comp.lang.javascript, IMO.

But - and this is important to note - that isn't standard javascript
that you're asking about. And I suspect that is the root cause of your
problem. Looking at the code, I can't tell WHAT addEvent() actually
does, since it's probably defined by the library you're using. You face
the same problem with injectInside. It looks to me like whoever build
the library you're using didn't fully test it on all browsers.

BTW, did you check Google?

If you read the first 4-5 results, you'll get a good education in the
problems you're facing.

Site Timeline