Tiberiu-Ionuț Stan Tiberiu-Ionuț Stan - 9 months ago 73
Javascript Question

JavaScript `onscroll` event standalone (without frameworks)

I need a standalone JavaScript

event handler (without frameworks such as jQuery, Prototype, mootools, etc.), which is also cross browser.

I have searched for one, I can only find thousands of examples using jQuery or Prototype.

Answer Source

From element.addEventListener:

    function onScrollEventHandler(ev)

    var el=window;

        el.addEventListener('scroll', onScrollEventHandler, false);   
    else if (el.attachEvent)
        el.attachEvent('onscroll', onScrollEventHandler);