get mouse position javascript

Solutions on MaxInterview for get mouse position javascript by the best coders in the world

showing results for - "get mouse position javascript"
Callum
29 Feb 2017
1// Cursor coordinate functions
2var myX, myY, xyOn, myMouseX, myMouseY;
3xyOn = true;
4
5function getXYPosition(e) {
6    myMouseX = (e || event).clientX;
7    myMouseY = (e || event).clientY;
8    if (document.documentElement.scrollTop > 0) {
9        myMouseY = myMouseY + document.documentElement.scrollTop;
10    }
11    if (xyOn) {
12        alert("X is " + myMouseX + "\nY is " + myMouseY);
13    }
14}
15function toggleXY() {
16    xyOn = !xyOn;
17    document.getElementById('xyLink').blur();
18    return false;
19}   
20
21document.onmouseup = getXYPosition;
Alessandra
04 Feb 2020
1<p>Click in the div element below to get the x (horizontal) and y (vertical) coordinates of the mouse pointer, when it is clicked.</p>
2
3<div onclick="showCoords(event)"><p id="demo"></p></div>
4
5<p><strong>Tip:</strong> Try to click different places in the div.</p>
6
7<script>
8function showCoords(event) {
9  var cX = event.clientX;
10  var sX = event.screenX;
11  var cY = event.clientY;
12  var sY = event.screenY;
13  var coords1 = "client - X: " + cX + ", Y coords: " + cY;
14  var coords2 = "screen - X: " + sX + ", Y coords: " + sY;
15  document.getElementById("demo").innerHTML = coords1 + "<br>" + coords2;
16}
17</script>
Julia
12 Mar 2016
1(function() {
2    document.onmousemove = handleMouseMove;
3    function handleMouseMove(event) {
4        var eventDoc, doc, body;
5
6        event = event || window.event; // IE-ism
7
8        // If pageX/Y aren't available and clientX/Y are,
9        // calculate pageX/Y - logic taken from jQuery.
10        // (This is to support old IE)
11        if (event.pageX == null && event.clientX != null) {
12            eventDoc = (event.target && event.target.ownerDocument) || document;
13            doc = eventDoc.documentElement;
14            body = eventDoc.body;
15
16            event.pageX = event.clientX +
17              (doc && doc.scrollLeft || body && body.scrollLeft || 0) -
18              (doc && doc.clientLeft || body && body.clientLeft || 0);
19            event.pageY = event.clientY +
20              (doc && doc.scrollTop  || body && body.scrollTop  || 0) -
21              (doc && doc.clientTop  || body && body.clientTop  || 0 );
22        }
23
24        // Use event.pageX / event.pageY here
25    }
26})();
27
queries leading to this page
document get mouse positionjs geting the mouse positionconsole mouse x and y on movemouse click x y javascriptget mouse pos in jsget position cursor javascripttooltip positioning event jsevent clientxget mouse pointer position in javascripthow to access clientxjavascript get mouse position on pagemouse position jsjs get mouse coordinateshow to get the dom position of mouse in javascriptmouseposition jsmouse x and yconsole log position of mouse pointer in javascripthtml how to get mouse positiondom event javascript clientxjs get mouse position x 2cyjavascript get mouse posiitonget mouse position in jsjs client posjs mouse coordinates windowget mouse pointer coords jshow to get the current mouse position in javascriptget mouse position javascript functionou mouse mouve get positionjavascript get position of mouse on pageget moiuse position in htmlhow to get mouse location in javascriptgett mouse position jsjs get mouse position windowevent mouse coordinates javascriptposition of mouse in jshow to know coordinate of mouse javascriptjavascript current mouse positionposition of mouse jsget mouse position in javascriptget position of mouse with javascriptjavascript get x y mousejs get mouse postitionhow to get mouse position javascript htmlmouse in and out javascriptjavascript log mouse positionjavascript get exact mouse positionclientx in javascriptjavascript get current mouse coordinatesget live coordinates of mouse with javascriptget mousex in jsjavascript get pointer positionget position of mouse in button jsevent mousexevent clientx javascripthow to get mouse position in javascriptjavascript track mouse positionhow to have clientx and clienty return coordinates of a particular element jsget current mouse position in javascriptjavascript mousemove get mouse positionhow to get mouse in javascripthow to get mouse cursor coordinate using jsjs events mouse xget coordinates from mouse eventhow to get the mouse position using javascripthow to get the coodernate of the mouse in javascriptjs mouse event positionconsole log mouse positionhow to find mouse coordinates in javascriptjavascript get cursor positionjs how to get mouse positionget x and y of mouse javascriptget exact mouse position javascriptmouse position js livejavascript get mouselocationjs detect mouse positionget current mouse location javascriptjavascript mouseover get coordinatescheck mouse position javascriptget x and y position of mouse javascriptgive clientx and clienty to div in javascriptjs get cursor position on documentjavascript getting mouse positionjs get mouse position in windowmouse coordinates jsis possible to control mouse position jshow to find mouse coordinates js get mouse click coordinates canvas jsget mouse location from event javascripthow to set x and y to move mouse in jsjavascript show current mouse positiontrack mouse pointer jsjavascript get pointer position addeventlistenerjavascript show mouse positionjavascript get current mouse positionmouse location javascriptposition mouse jshow to get mouse position in an elementget mouse pos jsclientx and clienty in jshow to track mouse position in jstrack mouse event javascriptdocument js get mouse positionusing javascript can i get the coordinates of the mouse pointerprint coordinates in jsjavascript position of cursorhow to track mouse position in javascriptjs getmouseposget mouse coordinates in javascriptevent clientxtrack cursor position javascriptget mouse coordinates jsset the mouse position in javascript how to know your pointer coordinates on html pageupdate mouse location javascriptget mouse position javasxcriptmouse x 2c y jsjavascript get mouse poiter positionget mouse location jsjavascript get position of mousehow to get the coordinate of our mouse in javascriptget mouse current position javascriptwindow mouse position jsjs mouse coordinatescords input javascriptget mouse position by jshow to find position of mouse pointer in javascriptmouse position on page javascriptwindow get mouse positionget mouse position of page in javascripttake mouse position javascriptshow mouse pointer location below the pointer in jsget the current mouse position javascriptget mouse x y coordinatesjs mouse pointer positionget mouse position on screenwrite text on cursor click using javascript event clientxmouse x position javascriptjs get mouse datafind mouse position javascriptvanilla js get cursor positiongetmouseposition 28event 29 javascriptget mouse position canvashow to print mouse position in javascriptjs get mousexhow to calculate mouse move y coordinates in javascriptmouse pos jsjavascript mouse event get coordinatesget x y position of mouse javascriptwant to get mouse position in jsjs track mouse locationjs get mouse x yjs mousemove get mouse positionget mouse position function javascriptjavascript mouse x and yjavascript get mouse locationjs event positionhjs mouse positionjs mouse event get mouse positionget mouse x position javascripttest mouse y 2fx jsjava script get mouse coordinateswhat is mouse x and y javascriptgetr mouse position jsjavascript position cursorclientx in javascripttmouse coordinates on clicktrack javascript mouse eventjavascript get mouse x and yget mouse with jsget cursor location javascriptget position of mouse codehs jsget cursor position javascriptjavascript track mouse positionget position mouse element javascriptget mouse yjs mouse event get mouse coordinatesget pointer position javascriptmousex jsjavascript get current mouse position clickget cursor position jstrack the mouse position with javascriptmouse x jsget mouse postiion javascriptconsole log mouse position jspos x and y in javascripthow to get the mouse position in js 3fget mouse position from eventget mouse coordinate jsget mouse coordinates in jsget mouse pos in hjavascriptmouse coordinate in jshow to get the mouse position in javascriptget coordinates of mouse click javascriptmouse event listener javascript mouse coordinatesjs get mouse posget mouse locartion jsjavascript get mouse position on mouse movejs track mousejavascript e xyevent get mouse positionget current position of mouse javascriptget position of mouse pointer javascriptjavascript get mouse click positionhtml canvas get mouse positionhow to get mouse x and y in javascriptjs get position of mousejs get mouse position in elementhow to get the cursor pointer position in jshow to get mouse xy xoordinates in jsget position mouse is on the element jsjavascrip current mouse positionmousemove coordinates javascripthow to detect the position of the mouse in javascriptshow x and y coordinates of mouse javascriptget pointer position on pagehow to get the position of the mouse in javascriptmouse x y javascripthow to find the mouse position in javascriptgetmousecoords javascriptcursor 27s position 28its x and y coordinates 29 jsgetmouseposition 28event 29 function javascriptjs document ouse positiontrack mouse pointer location jsget position of mouse on element jsjs get mouse position on click track mouse jshow to get the correct mouse position in javascriptjs get mousejs mouse move get cursor coordinatesget mouse coordinates on clickmouse position in javascripthow to get the mouse position in jstrack mouse pointer javascriptevent x javascriptget mouse position javascript relative to elementclientx javascripthow to read mouse position jshow to control mouse coordinates in javascriptmouse coordinates in javascripthow to get mouse coordinates with javascriptmouse x javascriptfind point of cursor javascriptget mouse pos in javascripthow to get current mouse coordinates jsjs track mouse positiontracking mouse position javascripthow to know the mouse place cordinats jshow to get mouse postion with javascriptget location of mouse javascriptdisplay the mouse x and y coordinates in jshow to get mouse position on a div in javascriptlisten to mouse location jsget mouse coordinates javascriptcursor position in javascripthow to get the mouse coordinates in javascriptjavascritpt get mouse positiontrack mouse position x and yjs get cordinates of the mousehow to get pointer position in javascript 5cmouse coordinates htmlhow to tie e client x and y to coordinates in cssmouse x and y javascriptjs display mouse coordinatesget x and y of mouse on screen jscoordinate of mouse htmlget mouse coordshow to get mouse pointer position in javascriptget mouse position jsjs get mouse cordsjavascript html mouse coordinatesjs get mouse coordsjavascript detect mouse position js log click locationget current mouse coordinates javascriptjavascript get mouse coordinatesjavascript client xmouse x mouse y java scripthow to get the cursor pointer coordinates using jsget position mouse javascriptjavascript event mousexjavascript html get current mouse positionposition mouse javascripthow to get the coordinates of the mouse in javascriptmousex javascriptmouse in mouse out javascriptposition of the mouse jsjavascript get co ordinates of mousehow to set mouse position in javascripthow to check mouse coordinates jsmouse position javascript htmlknow the position of the mouse javascriptjavascript event target coordinatesmouse pointer coordinates jsget mouse loaction in javascriptget position of mouse eventget mouse position xget pointer positionmouse offset javascriptget mouse position on clickget mouse input jsjavascript show mouse coordinatesjavascript get mouse position w3schoolsjavascript get mouse positionjavascript save mouse positionjs get mouse locationevent target coordinates htmljavascript listen mouse positionget position of mouse jsjavascript track mouse movementdetect mouse position javascriptget element mouse position javascriptjavascript get mouse position changehow to get coordinates of mouse click in javascriptget mouse x y coordinates javascripthow to get the coordinates of mouse in jsjs mouse xclientx jsjs get mouse positoinhow to get mouseposition javascriptget mouse x and y javascriptmouse position tracking javascriptjavascript mouse locationhow to get current mouse position in javascriptjs get element at mouse posmouse event pointer positionget mouse x javascriptjs get mouseposgettin mouse position jshow to track mouse movement in javascripthow to get mouse information javascriptjs have position of mouseget mouse position htmlget mouse position how to calculate mousemove y coordinates in javascriptget mouse position javascript in a divjavascript clientxjavascript how to get mouse x and yget mouse position javascript in divget mouse locationget coordinates on mouse mvoeget mouse positionjavascript mouse lockationselenium get mouse coordinates pythonjavascript get current mouse location get mouse positionmouse position eventclient x and y in reactjavascript mouse positionget current mouse position javascriptjs position cursorjavascript e clientxget mouse coordinates from eventmouse position javascriptjavascript get mouse position in elementhow to get x y mouse position in javascripthow to get mouse position jsmouse click coordinates javascripthtml get mouse positionhow to get exact coordinates of mouse click in javascriptget position of mouse in jsget y position of mouse javascriptmouse coordinate javascriptmouse x mouse y jsjavascript find the location of the mouseget mouse position in element javascripthow to get mouse position jsavascirptjavascript how to get mouse positionget mouse event coordinatesget position of cursor javascriptclientx property javascriptjavascript track mouse pointejs pointer positiontrack mouse position javascripthow to get mouse coordinates javascriptcurrent mouse position javascriptget element by mouse position javascripthow to get mouse position in the browser jshow to display mouse coordinates in javascriptjavascript get mouse positionget the mouse position javascriptget mouse position javascriptjavascript get mouse position on divget mouse coordinatesjavascript get x position of mousejavascript display mouse coordinatesjavascript get position mousehow to get mouse click position in javascriptjs get pointer positionhow to get mousemove position in javascriptmouse click position javascriptjavascript get mousepositonhow to get mouse coordinates on jsjavascript get mouse position without eventfind location of mouse pointer javascripthow to get access mouse on element in javascripthow to get position of mouse in javascripthow to get mouse coordinates in javascriptget mouse x jsjs getting mouse coords returning objecthow to detect mouse position in javascriptconsole log mouse positionjs mouse coordinates window determine mouse coordinates using jsget mouse position javascript on mouse moveposition of mouse in html javascriptjs get mouse coordinates on movehow to get mouse position in jsjquery clientxmouse coordinates in jsfind mouse coordinates jsclientx menu manager resetjavascript get element with mousehow to get current mouse location jsjavascript mouse position on htmls pageget user mouse position javascripthow to get mouse position javascriptget mouse position element javascripthtml get current mouse positionmouse coordinates javascriptjavascript get mouse position on hoverhow to make track the position of the mouse in javascriptaccess mouse position javascriptjavascript get users mouse positionjs get mouse positionmouse current position javascriptclientx and clienty in javascriptjs get mouse movementjavascript calculate mouse movementget the mouse x yfind mouse position javascipthow to get the mouse position jsjavascript get mouse coordinatejs mouse positionjs cursor positionget position of mouse javascriptjavascritp get mouse position relatiev to an elemtjava scrpt get mouse positionjs detect mouse coordinatesget mouse location javascriptjs get current mouse positionjavascript mouse positonget javasccript mouseknow mouse location javascriptmouse cursor position javascriptget pointer position jscapture x and y coordinates of mousetypescript get mouse location from eventhow to get cursor coordinates in javascriptget curser axis in jsjs get mouse position on mouse moveget mouse click coordinates javascriptgetting mouse position javascriptget mouse position on window javascripthtml javascript get mouse positionjavascript mouseevent positionevent clientx propertiesget position of element javascriptclientx of element in jsmouse position javascrpithow can we find the coords of mouse position jsgetmouseposition javascripthow to find mouse position in javascriptshow mouse position on canvas jsupdate mouse position javascriptposition of mouse javascriptunity get mouse positionjs get cursor positionjavascript track mouse pointerevent get mouse coordinatesget mouse position javascritcalculate the position of mouse on x axis javascripthow to get mouse coordinates on click in javascriptget mouse position javascript