📜  javascript onclick 选择坐标 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:59.560000             🧑  作者: Mango

代码示例1
var x;
var y;
if (e.pageX || e.pageY) { 
  x = e.pageX;
  y = e.pageY;
}
else { 
  x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; 
  y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; 
} 
x -= gCanvasElement.offsetLeft;
y -= gCanvasElement.offsetTop;