$ (document).scrollTop () always returns 0 - Stack Overflow
This code will work on all browser except for webkits browser such as chrome and safari because the tag always has a scrollTop value of zero or null. The other browsers ignore it while webkit's browsers don't.