javascript - How to find coordinates of mouse in HTML -


i need place img (image1.png) @ specific coordinates on html page. how can find coordinates of mouse when click? please write javascript (no jquery) function find x , y coordinates of mouse?

note: should mouse coordinates on html page, , not screen.

try this:

function getmousecoordinates(event) { var x, y;  x = event.clientx + document.body.scrollleft + document.documentelement.scrollleft; y = event.clienty + document.body.scrolltop + document.documentelement.scrolltop + 1;  return [x,y]; } 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -