+ 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?

6th Nov 2018, 8:03 AM
OM KASHYAP
OM KASHYAP - avatar
9 Respostas
6th Nov 2018, 6:35 PM
visph
visph - avatar
+ 3
Thanks a lot visph for your help..
7th Nov 2018, 5:53 AM
OM KASHYAP
OM KASHYAP - avatar
+ 2
function getMousePos() { var cursorX; var cursorY; document.onmousemove = function(e) { cursorX = e.pageX; cursorY = e.pageY; } // do something with coordinates... }
6th Nov 2018, 8:10 AM
Sokrat_Poghosyan
Sokrat_Poghosyan - avatar
+ 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); }; };
6th Nov 2018, 5:29 PM
visph
visph - avatar
+ 1
start writing on your own, then give a link of your code and “say look this thing is not working help me”
6th Nov 2018, 11:42 AM
Sokrat_Poghosyan
Sokrat_Poghosyan - avatar
+ 1
visph good job, now he won’t think about solving the problem.
7th Nov 2018, 8:34 AM
Sokrat_Poghosyan
Sokrat_Poghosyan - avatar
0
thanks NIk01 Can you give me an example from a code . it will be helpful..
6th Nov 2018, 10:41 AM
OM KASHYAP
OM KASHYAP - avatar
0
Ok
6th Nov 2018, 3:56 PM
OM KASHYAP
OM KASHYAP - avatar
0
Thank you for asking this question so I didnt have too
7th Oct 2020, 8:26 AM
Cam UOR
Cam UOR - avatar