SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2007
    Posts
    130
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Cursor Position Problem

    Hi! I have found this cursor position observer script that works great as long as you don't scroll down. But when you scroll down the cursor position becomes relative to the page, not the screen. Have a look and see for yourself: http://www.hscripts.com/scripts/Java...r-position.php

    What I want is the cursor position to be relative to the screen. So that when I scroll down while my cursor stays in the same position the cursor coordinates don't change.

    My JS knowledge is very basic so I hope someone can help me with this.

    It's a small script so it should be easy for anyone who knows what he or she is doing.

    Here's the code:

    HTML Code:
    <!--        Script by hscripts.com          -->
    <!--        copyright of HIOX INDIA         -->
    <!-- more scripts @ [url]http://www.hscripts.com[/url] -->
    
    <script language=javascript>
    window.onload = init;
    function init() {
      if (window.Event) {
        document.captureEvents(Event.MOUSEMOVE);
      }
      document.onmousemove = getXY;
    }
    
    function getXY(e) {
      x = (window.Event) ? e.pageX : event.clientX;
      y = (window.Event) ? e.pageY : event.clientY;
    
      // Use x and y to do what ever you want
    }
    </script>
    <!-- Script by hscripts.com -->

  2. #2
    Non-Member
    Join Date
    Aug 2007
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should get the height of browser and add/sub it


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •