access mouse position javascript

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

showing results for - "access mouse position javascript"
Bruno
13 May 2020
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;
Maximilian
26 Sep 2018
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>
Stefano
17 Aug 2019
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
js get mouse position in windowposition of mouse in jshow to tie e client x and y to coordinates in cssjs how to get mouse positionjavascript get pointer position addeventlistenerclientx in javascripttjavascript mouseevent positionposition of the mouse jstrack mouse pointer jshow to get mouse position in jsjavascript how to get mouse x and ymouse coordinates jsmouse x mouse y jsjs get mouse cordsjs event positionjs getmouseposjavascript get position of mousehow to get the correct mouse position in javascriptjavascript mousemove get mouse position get mouse positionget mouse position jsdisplay the mouse x and y coordinates in jsget mouse pos in jsjs mouse coordinates windowjs track mouse positiontypescript get mouse location from eventget mouse event coordinatesevent get mouse positiontracking mouse position javascriptjavascript track mouse movementjavascript find the location of the mousejava scrpt get mouse positionjs get mouse poshjs mouse positionhow to get mouse position javascript htmlposition of mouse javascriptget mouse pos in hjavascripthow to get mouse position on a div in javascriptmouse x jsget mouse position of page in javascriptgive clientx and clienty to div in javascripthow to get exact coordinates of mouse click in javascriptjavascript e clientxhow to get the mouse position jsjavascript mouse event get coordinatesget div mouse position javascripthow to calculate mouse move y coordinates in javascriptmouse click x y javascripthow to get cursor coordinates in javascriptjavascript get mouse coordinatesconsole log mouse positionmouse position eventjavascript show mouse coordinateshow to get mouse coordinates on click in javascriptget mouse x y coordinatesposition of mouse in html javascriptjavascript mouseover get coordinatesjavascript html get current mouse positionmousemove coordinates javascriptjavascript html mouse coordinatesknow the position of the mouse javascriptget position of mouse with javascriptjs mouse coordinatesget position of element javascripthow to get mouse click position in javascriptjavascript track mouse positionhow to get coordinates of mouse click in javascriptmouse position in javascriptget mouse position from eventprint coordinates in jsget cursor location javascripttrack mouse position x and yhow to get the mouse position in jsjavascript get pointer positionjavascript mouse locationgettin mouse position jsjavascript position cursortooltip positioning event jsevent clientxhow to get the dom position of mouse in javascriptis possible to control mouse position jsjavascript get mouse positionhow to get mouse postion with javascriptjavascritp get mouse position relatiev to an elemthow to get mousemove position in javascripttrack cursor position javascripthow to get mouse x and y in javascriptget position mouse element javascripthow to know coordinate of mouse javascripthow to get the coodernate of the mouse in javascriptconsole mouse x and y on movejs track mousecursor 27s position 28its x and y coordinates 29 jshow to get the mouse position in javascriptmousex jstrack the mouse position with javascriptget mouse position canvasget position of mouse pointer javascripthow to get mouse position in the browser jsjavascript log mouse positionhow to know your pointer coordinates on html pageget mouse coordinates jshow to get mouse position jshow to get mouse coordinates with javascriptget position mouse is on the element jsget current mouse location javascripthow to read mouse position jsget mouse click coordinates canvas jsget the current mouse position javascriptjs get mouse position windowcurrent mouse position javascriptunity get mouse positionget position of cursor javascriptget x y position of mouse javascriptjs get cordinates of the mousewhat is mouse x and y javascriptevent get mouse coordinateshtml get current mouse positionjavascript get mouse poiter positionjs mouse event get mouse positionget pointer position javascriptcords input javascriptget position of mouse in jstrack mouse position javascriptjavascript clientxfind point of cursor javascriptjs get mouse position in elementjavascript how to get mouse positionhow to get the cursor pointer position in jsjavascript detect mouse position javascript mouse positonjavascript show mouse positionget position of mouse javascriptposition mouse javascriptjavascript get mousepositonjs get mouse positionshow mouse pointer location below the pointer in jsjavascript track mouse positionjavascript get exact mouse positionhow can we find the coords of mouse position jsjs detect mouse coordinateshow to have clientx and clienty return coordinates of a particular element jsget mouse position in javascriptdom event javascript clientxget mouse position javascript functionjs get cursor position on documentjs get mouse positoinjs position cursorget mouse loaction in javascripthow to find position of mouse pointer in javascripthow to get the coordinates of the mouse in javascriptfind mouse position javasciptget mouse position on clickjs track mouse locationhow to detect the position of the mouse in javascriptjs get mouse coordinates on moveget mouse coordsget mouse coordinates javascripthow to get mouse location in javascriptclientx menu manager resetget the mouse x yjs events mouse xhow to get the current mouse position in javascriptget mouse position xclientx jsget cursor position javascriptjavascript mouse positionmouse x y javascripthow to get mouse position in javascriptusing javascript can i get the coordinates of the mouse pointerclientx and clienty in javascriptget cursor position jsmouse event pointer positionjavascript get element with mouseget the mouse position javascripthow to get the cursor pointer coordinates using jsfind location of mouse pointer javascriptclientx javascriptjavascript getting mouse positionget mouse position javascritget mouse current position javascriptget x and y position of mouse javascriptwant to get mouse position in jsget mouse locartion jsposition mouse jsjs get element at mouse posmouse position tracking javascripthow to calculate mousemove y coordinates in javascriptjavascript get current mouse positionupdate mouse position javascriptget mouse position htmljavascript mouse x and ylisten to mouse location jsmouse coordinates on clickmouse position on page javascriptget mouse x y coordinates javascriptget mouse coordinateshow to detect mouse position in javascriptget mouse position in jsmouse x mouse y java scriptget user mouse position javascripthow to track mouse movement in javascriptjs get mousexget mouse pos jsjavascript event mousexjs get mouse x yjs get mouse position on click javascript get mouse position on hovercursor position in javascripthow to get current mouse coordinates jsclientx and clienty in jshow to know the mouse place cordinats jsmouse click position javascripthtml canvas get mouse positionevent clientxmouse coordinates in jsget mouse x position javascriptget mouse coordinates on clickmouse coordinates in javascripttrack javascript mouse eventget mouse position element javascriptevent mousexjs get mouse position x 2cyjavascritpt get mouse positionget mouse position function javascriptmouse coordinates javascriptjs detect mouse positionvanilla js get cursor positionget current mouse position in javascripthow to check mouse coordinates jshow to get mouse in javascriptjavascript get x y mousejavascript get x position of mousehow to get current mouse position in javascripthow to get the mouse position using javascriptcapture x and y coordinates of mouseget mouse coordinates in jsget mouse coordinate jsjavascript get mouse position in element on mousemovejs mouse move get cursor coordinatesjavascript current mouse positionhow to get mouseposition javascriptget javasccript mousejavascript track mouse pointerget live coordinates of mouse with javascriptmouse position js livemouse position jsdocument js get mouse positionget mouse position javascript on mouse movejavascript show current mouse positionjavascript get cursor positionget x and y of mouse on screen jsjs mouse xjs get mouse movementget coordinates of mouse click javascriptclientx property javascriptget mouse coordinates in javascriptselenium get mouse coordinates pythonget position of mouse codehs jsclientx in javascriptjavascript calculate mouse movementjavascript event target coordinatesget pointer position on pagewindow get mouse positionjs mousemove get mouse positionget current mouse position jshow to print mouse position in javascriptjavascript track mouse pointeconsole log position of mouse pointer in javascriptjs getting mouse coords returning objectget mouse click coordinates javascriptmouse in mouse out javascriptjs document ouse positionget mouse position how to find mouse coordinates in javascriptevent clientx propertiesjs get mouse coordinateshow to get mouse xy xoordinates in jsjavascript get mouse x and yjs mouse coordinates window get mouse pointer position in javascriptget element mouse position javascriptjavascript get mouse position changeposition of mouse jsget element by mouse position javascriptfind mouse position javascriptjava script get mouse coordinateshow to get mouse position javascriptget mouse x jsshow x and y coordinates of mouse javascriptevent target coordinates htmljavascript get position of mouse on pageconsole log mouse positionhow to make track the position of the mouse in javascripttake mouse position javascriptmouse x position javascriptevent clientx javascriptget div from mouse position javascriptget current mouse coordinates javascriptget mousex in jswrite text on cursor click using javascript event clientxget mouse position javasxcriptget mouse pos in javascripthow to get the position of the mouse in javascripthow to get mouse position jsavascirptmouse offset javascriptshow mouse position on canvas jsmouse position javascriptget mouse location from event javascripthow to find mouse position in javascriptjs log click locationcheck mouse position javascriptjavascript position of cursorget mouse location jsget position cursor javascriptget mouse yget exact mouse position javascripthow to set mouse position in javascriptjavascript get mouse locationjs mouse pointer positionjs get current mouse positiongetmouseposition 28event 29 function javascriptget mouse location javascriptjavascrip current mouse positionjs get position of mousegetting mouse position javascriptgetmouseposition 28event 29 javascriptget mouse pointer coords jsget pointer positionclient x and y in reacthow to display mouse coordinates in javascriptgett mouse position jsjavascript get current mouse position clickhow to get mouse pointer position in javascriptmouse position javascrpitclientx of element in jsjavascript get current mouse locationget mouse position javascriptget position of mouse in button jshow to get mouse cursor coordinate using jshow to get the mouse position in js 3fjs get mouse datamouse x and yhow to get current mouse location jsjs get mouse postitionhow to get the coordinates of mouse in jsjs mouse event get mouse coordinateshow to track mouse position in jswindow mouse position jstrack mouse pointer javascriptjavascript listen mouse positioncalculate the position of mouse on x axis javascriptjavascript get mouselocationmouse click coordinates javascripthow to get the mouse coordinates in javascriptjs geting the mouse positionjs get mousejs display mouse coordinatesmouse x 2c y jsjavascript display mouse coordinatespos x and y in javascriptget mouse x and y javascriptmouse event listener javascript mouse coordinatesget mouse input jshow to get position of mouse in javascriptget mouse position javascript relative to elementjavascript get mouse click positionjs mouse event positionget mouse coordinates from eventmouse in and out javascriptjquery clientxhow to set x and y to move mouse in jsjavascript e xyjavascript get mouse coordinatehow to control mouse coordinates in javascriptget y position of mouse javascripthtml get mouse positiondocument get mouse positionmouse current position javascriptget mouse position div javascriptmouse pos jsevent x javascriptjs get cursor positionhow to find mouse coordinates js get x and y of mouse javascriptget curser axis in jsjavascript get users mouse positionhow to get mouse coordinates in javascriptjavascript get mouse position on divmouse coordinate in jshtml javascript get mouse positionjs pointer positionmouse position javascript htmljs get pointer positiondetermine mouse coordinates using jsjs get mouse position on mouse moveaccess mouse position javascriptmouse x and y javascriptget mouse x javascriptjs mouse positionjavascript get co ordinates of mouseget mouse position javascript in divhow to get mouse coordinates on jsjavascript get mouse position on pagetrack mouse pointer location jsmouseposition jsjs get mouse coordsjavascript get mouse position on mouse movejavascript mouse position on htmls pagetrack mouse jsget mouse positionhow to get mouse information javascriptconsole log mouse position jshtml how to get mouse positionget coordinates from mouse eventhow to find the mouse position in javascriptmouse pointer coordinates jsjavascript get mouse position in elementjavascript get mouse position w3schoolsfind mouse coordinates jsget position of mouse jshow to get pointer position in javascript 5cjs cursor positionget mouse locationknow mouse location javascriptjs get mouse locationgetmousecoords javascriptget position of mouse eventmousex javascriptjavascript client xgetmouseposition javascriptgetr mouse position jsmouse cursor position javascriptjs get mouseposget pointer position jscoordinate of mouse htmlevent mouse coordinates javascriptmouse coordinates htmljs client posget mouse position on window javascriptget moiuse position in htmlmouse coordinate javascriptjavascript get mouse positionget current mouse position javascriptget mouse position javascript in a divhow to get access mouse on element in javascriptget coordinates on mouse mvoeget location of mouse javascriptget mouse position on screenmouse x javascriptget position mouse javascripthow to get the coordinate of our mouse in javascripttest mouse y 2fx jsupdate mouse location javascriptget mouse event positionmouse location javascriptou mouse mouve get positionhow to get mouse position in an elementjavascript get mouse position without eventtrack mouse event javascripthow to get x y mouse position in javascripthow to access clientxjavascript get position mousejavascript get current mouse coordinatesjavascript mouse lockationset the mouse position in javascript javascript save mouse positionhow to get mouse coordinates javascripthow to track mouse position in javascriptget mouse postiion javascriptget mouse with jsdetect mouse position javascriptjavascript get mouse posiitonget position of mouse on element jsget mouse position by jsget current position of mouse javascriptjs have position of mouseget mouse position in element javascriptaccess mouse position javascript