Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6142631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:24:50+00:00 2026-05-23T18:24:50+00:00

how can i get the mouse position when i scroll down or scroll up

  • 0

how can i get the mouse position when i scroll down or scroll up

i tried this

$(document).mousemove(function(event) {
    captureMousePosition(event);
}).scroll(function(event) {
    xMousePos = event.pageX + $(document).scrollLeft();
    yMousePos = event.pageY + $(document).scrollTop();
    window.status = "x = " + xMousePos + " y = " + yMousePos;
});

function captureMousePosition(event){
    xMousePos = event.pageX;
    yMousePos = event.pageY;
    window.status = "x = " + xMousePos + " y = " + yMousePos;
}

but didnt worked i want the exact position of mouse relative to the top of page not in respect to window(frame)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:24:51+00:00Added an answer on May 23, 2026 at 6:24 pm

    we cannot get mouse current position on scroll we can just get how much it scrolled relative to last position
    so changed it to :

    var xMousePos = 0;
    var yMousePos = 0;
    var lastScrolledLeft = 0;
    var lastScrolledTop = 0;
    
    $(document).mousemove(function(event) {
        captureMousePosition(event);
    })  
    
        $(window).scroll(function(event) {
            if(lastScrolledLeft != $(document).scrollLeft()){
                xMousePos -= lastScrolledLeft;
                lastScrolledLeft = $(document).scrollLeft();
                xMousePos += lastScrolledLeft;
            }
            if(lastScrolledTop != $(document).scrollTop()){
                yMousePos -= lastScrolledTop;
                lastScrolledTop = $(document).scrollTop();
                yMousePos += lastScrolledTop;
            }
            window.status = "x = " + xMousePos + " y = " + yMousePos;
        });
    function captureMousePosition(event){
        xMousePos = event.pageX;
        yMousePos = event.pageY;
        window.status = "x = " + xMousePos + " y = " + yMousePos;
    }
    

    it worked and is working on multi browsers….

    anyways thanks all 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get text at mouse position? I have now some like this
I have a circle when mousemove I can get e.GetPosition(this). But how to programmatically
How can I get in Mac OS X global mouse position - I mean
What are event and UI parameters in jQuery Dialog? Can I get a mouse
How can I get a UIElement to ignore mouse clicks on it and pass
I can get the element like this $(#txtEmail) but I'm not sure how to
I want to get hold of the mouse position in a timeout callback. As
Using the flot js graphing library, you can get the (x,y) position of the
I can use [NSEvent mouseLocation] to get the cursor's location, but this gives me
This code runs well with jQuery-1.3.2.min.js but doesn't run with jQuery-1.6.2.min.js . $(function(){ $(document).mousedown(mouseUpAfterDrag);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.