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 7831297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:39:54+00:00 2026-06-02T11:39:54+00:00

I just threw this little mouse tracking example together when I realized, that it

  • 0

I just threw this little mouse tracking example together when I realized, that it throws thousands of errors in the chrome console.

Uncaught TypeError: Cannot read property 'clientX' of undefined

AFAIK this means, that chrome can’t find the object that this property belongs to. But if I open the example, it shows the right coordinates perfectly fine. Please help me to get rid of these useless errors.

<html>
<head>
    <style type="text/css">
        #tracking {
            width: 300px;
            height: 300px;
            background-size: 300px 300px;
            background-color: #00F;
            left: 100px;
            top: 100px;
            position: absolute;
        }
    </style>
    <script type="text/javascript">
        var mX, mY;
        var track;
        document.onmousemove = update;

        function trackload()
        {
            track = document.getElementById("tracking");
            setTimeout("update()",10);
        }

        function update(e)
        {
            mX = e.clientX;
            mY = e.clientY;
            if (track) {
                track.innerHTML = "X: " + mX + " Y: " + mY + " deg: " + (Math.atan(mY / mX) * (180/Math.PI));
                track.style.cssText = "-webkit-transform: rotate(" + (Math.atan(mY / mX) * (180/Math.PI)) + "deg);";}
            setTimeout("update()",10);
        }
    </script>
</head>
<body>
    <div id="tracking" onclick="trackload()"></div>
</body>

  • 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-06-02T11:39:56+00:00Added an answer on June 2, 2026 at 11:39 am

    Remove the calls to setTimeout to prevent the error. It occurs because the update function expects an event object, which is not passed in when you call the function through the setTimeout. Therefore e is undefined, and you get your error.

    Here’s a working example.

    If there was a good reason for the setTimeout calls, you will need to explain it as I can’t work out why they are needed at first glance. As a side note, passing a string to setTimeout is generally considered bad practice (it’s an alias for eval). You can just pass a reference to the function.

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

Sidebar

Related Questions

I have this little piece of code that just checks for a particular text
This just started happening three weeks or so ago. The content of my website
if ConvertAll throw an exception on one element, can i just skip this element
Lets just say that I have three textboxes: TextBox1, TextBox2, TextBox3. Normally if I
I'm setting up a program that has three different windows. I'm just using ..
Just to make sure I'm understanding shallow copies of reference types correctly and that
I have this little jQuery plugin: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd>
I just need a little advice on what may be the best method for
I tend to get surprised these days, but this little bugger really owned me
I'm writing a little JavaScript tool for myself that I plan on making available

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.