get mouse position javascript
JavaScript
<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>
<div onclick="showCoords(event)"><p id="demo"></p></div>
<p><strong>Tip:</strong> Try to click different places in the div.</p>
<script>
function showCoords(event) {
var cX = event.clientX;
var sX = event.screenX;
var cY = event.clientY;
var sY = event.screenY;
var coords1 = "client - X: " + cX + ", Y coords: " + cY;
var coords2 = "screen - X: " + sX + ", Y coords: " + sY;
document.getElementById("demo").innerHTML = coords1 + "<br>" + coords2;
}
</script>// Cursor coordinate functions
var myX, myY, xyOn, myMouseX, myMouseY;
xyOn = true;
function getXYPosition(e) {
myMouseX = (e || event).clientX;
myMouseY = (e || event).clientY;
if (document.documentElement.scrollTop > 0) {
myMouseY = myMouseY + document.documentElement.scrollTop;
}
if (xyOn) {
alert("X is " + myMouseX + "\nY is " + myMouseY);
}
}
function toggleXY() {
xyOn = !xyOn;
document.getElementById('xyLink').blur();
return false;
}
document.onmouseup = getXYPosition;
Also in JavaScript:
- Title
- edit onclick event
- Category
- JavaScript
- Title
- how to make an async function
- Category
- JavaScript
- Title
- how to access a database in express
- Category
- JavaScript
- Title
- document addeventlistener click
- Category
- JavaScript
- Title
- how to make a page relode on a keypress in js
- Category
- JavaScript
- Title
- html decode javascript
- Category
- JavaScript
- Title
- concat js mdn
- Category
- JavaScript
- Title
- fixed div with scrollable content
- Category
- JavaScript
- Title
- change id in jquery
- Category
- JavaScript
- Title
- how to remove 000webhost watermark 2019
- Category
- JavaScript
- Title
- console.log in jsx
- Category
- JavaScript
- Title
- bracket notation javascript
- Category
- JavaScript
- Title
- how to add ' in javascript string
- Category
- JavaScript
- Title
- array unique values javascript
- Category
- JavaScript
- Title
- hover jquery
- Category
- JavaScript
- Title
- append img to svg d3 js
- Category
- JavaScript
- Title
- initialize array javascript
- Category
- JavaScript
- Title
- faker js
- Category
- JavaScript
- Title
- how to import npm packages in node.js?
- Category
- JavaScript
- Title
- how to update angular version
- Category
- JavaScript
- Title
- explode in jquery
- Category
- JavaScript
- Title
- how to do bubble sort in javascript
- Category
- JavaScript
- Title
- hide element by name javascript
- Category
- JavaScript
- Title
- how to get mouse coordinates in javascript
- Category
- JavaScript
- Title
- disable autocomplete javascript
- Category
- JavaScript
- Title
- get react version
- Category
- JavaScript
- Title
- how to display image in html from json object
- Category
- JavaScript
- Title
- how to make background image move mmousemove jquery
- Category
- JavaScript
- Title
- compare dates in js
- Category
- JavaScript
- Title
- getFullYear within moment in angular
- Category
- JavaScript
- Title
- how to add property to object in javascript
- Category
- JavaScript
- Title
- enzyme check state
- Category
- JavaScript
- Title
- form submit programmatically
- Category
- JavaScript
- Title
- how to parse query string in node.js lambda
- Category
- JavaScript
- Title
- ionic cordova icon notification
- Category
- JavaScript
- Title
- hwo to cehck req header in js
- Category
- JavaScript
- Title
- create a react native project
- Category
- JavaScript
- Title
- array javascript
- Category
- JavaScript
- Title
- how to attach javascript to html
- Category
- JavaScript
- Title
- delegate jquery
- Category
- JavaScript
- Title
- express bodyparser deprecated
- Category
- JavaScript
- Title
- angular observable subscribe and unsubscribe
- Category
- JavaScript
- Title
- bash parse json
- Category
- JavaScript
- Title
- how to redirect react router from the app components
- Category
- JavaScript
- Title
- assign values to a table from javascript in VF page
- Category
- JavaScript
- Title
- export component in
- Category
- JavaScript
- Title
- addEventListener
- Category
- JavaScript
- Title
- add a slash to string in javascript
- Category
- JavaScript
- Title
- adding a variable to a string without using + in javascript
- Category
- JavaScript
- Title
- Javascript compare two objects
- Category
- JavaScript
- Title
- apache log format json
- Category
- JavaScript
- Title
- boucle foreach js
- Category
- JavaScript
- Title
- How to check whether a string contains a substring in JavaScript?
- Category
- JavaScript
- Title
- how to have your discord bot send two message
- Category
- JavaScript
- Title
- componentWillUnmount functional component for asynchronous requests
- Category
- JavaScript
- Title
- how to add onclick event in javascript
- Category
- JavaScript
- Title
- inner html jquery
- Category
- JavaScript
- Title
- add set time out in jquery
- Category
- JavaScript
- Title
- html loop through array
- Category
- JavaScript
- Title
- Cannot set property 'innerHTML' of null
- Category
- JavaScript
- Title
- dropzone add download button addedfile
- Category
- JavaScript
- Title
- bq show pretty json
- Category
- JavaScript
- Title
- get date now javascript
- Category
- JavaScript
- Title
- how to open bash_profile
- Category
- JavaScript
- Title
- fetch get data js
- Category
- JavaScript
- Title
- how to get the next item in map() js
- Category
- JavaScript
- Title
- add char in specific index stirng javascript
- Category
- JavaScript
- Title
- how to paste in input field react native
- Category
- JavaScript
- Title
- extend react.component
- Category
- JavaScript
- Title
- input in javascript
- Category
- JavaScript
- Title
- block comment js
- Category
- JavaScript
- Title
- how to get data from localstorage in javascript
- Category
- JavaScript
- Title
- create a json object in javascript
- Category
- JavaScript
- Title
- how to compare two strings in javascript if condition
- Category
- JavaScript
- Title
- include gif in react
- Category
- JavaScript
- Title
- array shift javascript
- Category
- JavaScript
- Title
- express how to access ajax post data
- Category
- JavaScript
- Title
- bind and unbind jquery validation
- Category
- JavaScript
- Title
- event target javascript
- Category
- JavaScript
- Title
- how to send an alert in javascript
- Category
- JavaScript
- Title
- hello world javascript
- Category
- JavaScript
- Title
- array vowels js
- Category
- JavaScript
- Title
- how to log an array in javascript
- Category
- JavaScript
- Title
- events js 292 throw er Unhandled 'error' event ^ Error getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0 at GetAddrInfoReqWrap.onlookup [as oncomplete]
- Category
- JavaScript
- Title
- how to add changes every time you route navigate to page in angular
- Category
- JavaScript
- Title
- check array values equal js
- Category
- JavaScript
- Title
- how to render different pages in nodes
- Category
- JavaScript
- Title
- JavaScript banner
- Category
- JavaScript
- Title
- javascript array concat spread operator
- Category
- JavaScript
- Title
- compile angularjs template
- Category
- JavaScript
- Title
- how to get the end of an array javascript
- Category
- JavaScript
- Title
- javascript check if string is number
- Category
- JavaScript
- Title
- how to instialise var in js
- Category
- JavaScript
- Title
- group all items with same name js
- Category
- JavaScript
- Title
- append to array js
- Category
- JavaScript
- Title
- dynamodb get all items nodejs
- Category
- JavaScript
- Title
- how to write in js
- Category
- JavaScript
- Title
- checking object is empty in JS
- Category
- JavaScript
- Title
- difference between e.preventdefault and e.stoppropagation and return false
- Category
- JavaScript
- Title
- how to debug javascript
- Category
- JavaScript