+ 1
How can I get the coordinates of the position where user clicked the screen ?
I want to know that how can i get the coordinates of the place where user right-clicks the place In javascript?
9 Antworten
+ 3
visual demo:
https://code.sololearn.com/Wvmn0GU9r265/?ref=app
+ 3
Thanks a lot visph for your help..
+ 2
function getMousePos() {
var cursorX;
var cursorY;
document.onmousemove = function(e) {
cursorX = e.pageX;
cursorY = e.pageY;
}
// do something with coordinates...
}
+ 2
onload = () => {
document.documentElement.onclick = e => {
console.log('click '+e.pageX+','+e.pageY);
};
document.documentElement.oncontextmenu = e => {
console.log('right-click '+e.pageX+','+e.pageY);
};
};
+ 1
start writing on your own, then give a link of your code and “say look this thing is not working help me”
+ 1
visph good job, now he won’t think about solving the problem.
0
thanks NIk01
Can you give me an example from a code . it will be helpful..
0
Ok
0
Thank you for asking this question so I didnt have too