Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Apr 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tool to determine (X,Y) coordinates

    Hi,

    Is there any tool that can determine the (x,Y) position of a certain pixel on my screen?

    Many thanks,
    Xibi

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    maybe of a certain object, not of a certain pixel. Pixels are measurement units, not objects... So? You need to know the absolute coordinates of an object (the left-top corner)?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Apr 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your help.

    I meant a tool that can provide me with the ability to point on a certain pixel in my screen with my mouse, and it will tell me exact (X,Y) coordinate of that pixel.
    Otherwise for me (as a not experienced javascripter) positioning is trial and error.

    Hope it's clear,
    Xibi

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Aha, you want to know in fact the position of the mouse measured in pixels. Here's a variant which will show the coordinates of the mouse onclick:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/JavaScript">
    var posx;var posy;
    function getMouse(e){
    posx=0;posy=0;
    var ev=(!e)?window.event:e;//IE:Moz
    if (ev.pageX){//Moz
    posx=ev.pageX+window.pageXOffset;
    posy=ev.pageY+window.pageYOffset;
    }
    else if(ev.clientX){//IE
    posx=ev.clientX+document.body.scrollLeft;
    posy=ev.clientY+document.body.scrollTop;
    }
    else{return false}//old browsers
    document.onclick=function(){
    document.getElementById('mydiv').firstChild.data='X='+posx+' Y='+posy;
    }
    }
    </script>
    </head>
    <body onmousemove="getMouse(event)">
    <div id="mydiv">&nbsp;</div>
    </body>
    </html>
    Last edited by Kor; 07-27-2006 at 10:02 AM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New Coder
    Join Date
    Apr 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks.

  • #6
    Regular Coder RexxCrow's Avatar
    Join Date
    Jul 2006
    Location
    California
    Posts
    275
    Thanks
    6
    Thanked 2 Times in 2 Posts
    I have a question on this, could this be taken a step further an used in conjunction with creating a floating menu that follows along from its top or middle both for horizontally and vertically aligned menus? That would be pretty neato!


  •  

    Posting Permissions

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