最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

prototypejs - Javascript: onScroll event (using Prototype) doesn't work on IE? - Stack Overflow

programmeradmin1浏览0评论

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

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

Share Improve this question edited Dec 28, 2011 at 15:53 Tom van der Woerdt 30k7 gold badges74 silver badges105 bronze badges asked Jul 7, 2009 at 5:26 ChetaneChetane 2401 gold badge3 silver badges10 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 13

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.

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...

发布评论

评论列表(0)

  1. 暂无评论