Javascript: onScroll event (using Prototype) doesn't work on IE?

13,453

Solution 1

Try attaching it to the window instead:

Event.observe(window, 'scroll', function() {
        alert('boo');
});

Works for me on IE, FF. Honestly, I don't know why it would work attaching it to the document.

Solution 2

Don't know if anyone is still following this answer, but i thought i would put down some of the information i found. In general the scroll event is supported on "window" on the following browsers below...

  • IE 5,6,7,8 (don't know about 9)
  • FF all versions
  • Safari 3.0.. up
  • Chrome
  • Opera 9.0.. up

However, when it comes to the document, it is not supported on any of the IE versions. Now, the funny thing is the Iphone 3G browser is the reverse of IE. The scroll event only works on the document. For more info on this, check out http://www.quirksmode.org. This site has alot of good stuff on event handling. Hope this helps someone...

Share:
13,453
Chetane
Author by

Chetane

Updated on June 23, 2022

Comments

  • Chetane
    Chetane about 2 years

    I am trying to trigger the onScroll event this way using prototype:

    Event.observe(document, 'scroll', function(){
        alert('boo');
    });
    

    It works perfectly on Firefox, but nothing happens on IE. Does anyone know why? and if there is another way to do so?

    Thanks