Is there any way in javascript to check if web page has been vertically scrolled? specially for Internet Explorer? I need to get the mouse position in IE but using jQuery event e.pageY it gives correct value when page is not scrolled but when page is scrolled down then it gives wrong position.
            Asked
            
        
        
            Active
            
        
            Viewed 3.2k times
        
    2 Answers
48
            
            
        if (!$(window).scrollTop()) { // abuse 0 == false :)
  alert("You are at the top of this window");
}
 
    
    
        double-beep
        
- 5,031
- 17
- 33
- 41
 
    
    
        Nick Craver
        
- 623,446
- 136
- 1,297
- 1,155
- 
                    2Or without jQuery `if(window.pageYOffset == 0) {alert("Top of the window");}` – Kalimah Apr 16 '19 at 03:22
3
            Check out this question if you are comfortable with using jQuery:
How do I determine height and scrolling position of window in jQuery?
 
    
    
        Community
        
- 1
- 1
 
    
    
        Peter Jaric
        
- 5,162
- 3
- 30
- 42
- 
                    1thanks a lot. my problem is solved. i just need $(window).scrollTop. – Muzzammil Hussain Jun 19 '10 at 08:19
- 
                    Jquery might not be the first choice anymore. I strongly recommend looking into the IntersectionObserver which by now is even a native browser feature. Besides becoming the new standard it also is better from a performance standpoint. – Niklas Mar 28 '22 at 13:13
 
    