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

  • SEARCH
  • Home
  • 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 746153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:39:58+00:00 2026-05-14T09:39:58+00:00

I am trying to track mouse movements in the browser, and if a user

  • 0

I am trying to track mouse movements in the browser, and if a user stops their mouse for 0.5 seconds, to execute some code. I have put a breakpoint in the code below in firebug, and it breaks on the var mousestop = function(evt) line, but then jumps to the return statement. Am I missing something simple? Why isn’t it executing the POST statement? I am tracking mouse clicks in a similar way, and it posts to the server just fine. Just not mouse stops.

$.fn.saveStops = function() {
$(this).bind('mousemove.clickmap', function(evt) {
    var mousestop = function(evt) {
          $.post('/heat-save.php', {  
                x:evt.pageX,  
                y:evt.pageY,
                click:"false",
                w:window.innerWidth,
                h:window.innerHeight,
                l:escape(document.location.pathname) 
            }); 
      }, 
      thread;

      return function() {
        clearTimeout(thread);
        thread = setTimeout(mousestop, 500);
      };

});
};
  • 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-14T09:39:59+00:00Added an answer on May 14, 2026 at 9:39 am

    Could evt be undefined by the time mousestop is executed?

    Try it like this:

          return function() {
            clearTimeout(thread);
            thread = setTimeout(function(){mousestop(evt);}, 500);
          };
    

    here is how i would refactor:

    // a closure for good measure...
    (function($){
        var mousestop = function(evt){
                // I would use GET because POST makes 2 round trips
                $.get("/heat-save.php", {  
                    "x":evt.pageX,  
                    "y":evt.pageY,
                    "click":false,
                    "w":window.innerWidth,
                    "h":window.innerHeight,
                    "l":escape(document.location.pathname)
                }); 
            },
            thread = null;
        $.fn.saveStops = function() {
            return this.bind("mousemove.clickmap", function(evt) {
                clearTimeout(thread);
                thread = setTimeout(function(){mousestop(evt);}, 500);
            });
        };
    }(jQuery));
    

    You can event replace the ajax calls with something like this:

    (new Image).src = "/heat-save.php?x=" + evt.pageX + "&y=" + evt.pageY + "&click=false&w=" + window.innerWidth + "&h=" + window.innerHeight + "&l=" + escape(document.location.pathname;
    

    POST vs GET

    Also, make sure your server sends back a “204 No Content” status code instead of 200 for the speediest responses.

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

Sidebar

Related Questions

I'm trying to track down some bugs experienced by a user. I'm just thinking
I am trying to track down all stored procedures in a database that have
I'm trying to track down an issue in our system and the following code
We're trying to track down some .Net assembly dependency problems. On Windows XP, does
I'm trying to track down an issue in our MFC code that looks like
I have a function that tracks the user's mouse to show them visually where
I'm trying to track down some problems with unit tests in a test TFS
I'm trying to trace the mouse X position with a movieclip. What I have
Trying to track down this error I get when I have NSZombieEnabled . I
I'm trying to simply track the mouse over my canvas tag, and log how

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.