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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:16:16+00:00 2026-06-10T12:16:16+00:00

First version does not show me x and y and get I get following

  • 0

First version does not show me x and y and get I get following error:

Uncaught TypeError: Cannot read property ‘pageX’ of undefined

The Second version works but is very similar coded, can’t find the problem.

FIRST VERSION (NOT WORKING)

    <form name ="show">
        <input type="text" name="mouseXField" value="0" size="6">Mouse X Position<br>
        <input type="text" name="mouseYField" value="0" size="6">Mouse Y Position<br>
    </form>
        
        <script type="text/javascript">
        
        var mie = (navigator.appName == "Microsoft Internet Explorer") ? true : false;
        
        if (!mie) {                
            document.captureEvents(Event.MOUSEMOVE);
            document.captureEvents(Event.MOUSEDOWN);
        }
                    
        document.onmousemove = mousePos();
        document.onmousedown = mouseClicked();
        
        var mouseClick;
        var keyClicked;
        
        var mouseX = 0;
        var mouseY = 0;
        
        function mousePos (e) {                
            if (!mie) {
                mouseX = e.pageX; 
                mouseY = e.pageY;
            }
            else
                mouseX = event.clientX + document.body.scrollLeft;
                mouseY = event.clientX + document.body.scrollTop;
                   
        document.show.mouseXField.value = mouseX;
        document.show.mouseYField.value = mouseY;
        
        return true;
        }
        
        </script> 

SECOND VERSION (WORKING)

      <form name="Show">
            <input type="text" name="MouseX" value="0" size="4"> X<br>
            <input type="text" name="MouseY" value="0" size="4"> Y<br>
      </form>

        <script type="text/javascript">

            var IE = document.all?true:false

            if (!IE) document.captureEvents(Event.MOUSEMOVE)

            document.onmousemove = getMouseXY;

            var tempX = 0
            var tempY = 0

            function getMouseXY(e) {
                if (IE) {       
                tempX = event.clientX + document.body.scrollLeft
                tempY = event.clientY + document.body.scrollTop
                } 
                else 
                {  
                 tempX = e.pageX
                 tempY = e.pageY
                }  

                document.Show.MouseX.value = tempX
                document.Show.MouseY.value = tempY

                return true
                }
        </script>     
  • 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-10T12:16:18+00:00Added an answer on June 10, 2026 at 12:16 pm

    On a first sight: clientX should be clientY and missing {} in your else:

    else {
       mouseX = event.clientX + document.body.scrollLeft;
       mouseY = event.clientY + document.body.scrollTop;
    }
    

    Also you need to send the event to the function,

    document.onmousemove = function (e) {mousePos(e);};
    ...
    function mousePos (e) {
    ...
    

    check this out: http://jsfiddle.net/NLsdZ/1/

    Also, use of captureEvents is deprecated, you should use addEventListener instead. More info here: http://forums.asp.net/t/1576872.aspx

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

Sidebar

Related Questions

I benchmarked 2 version of my solr index the first with the following include
When code is placed onClick event it does not show open save dialog box
Well, in my first version of my service, I have a duplex contract, so
Here is the example with comments: class Program { // first version of structure
I have like 400 records on my database, suppose this is the first version
I'm want to display different image version: first article: big banner second: small banner
I struggle to uninstall VS 2010. I downloaded and used first trial version for
First off, let me define the end goal: I'd like to Wordpress (version 2.8)
Currently using MySQL version 5.1.6 This is my first real world build and so
In the unix/linux version, I'd simply change the first line: #!perl -i.bak Using Activestate

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.