JSFiddle - React, Tailwind, and code Playground
by seong gyun jeon
JavaScript
document.onclick = function (e) {
e = e || window.event;
var x = 0, y = 0;
var scroll = scroll();
if (e.pageX && e.pageY) {
x = e.pageX;
y = e.pageY;
}
else if (e.clientX && e.clientY) {
x = e.clientX + scroll.x;
y = e.clientY + scroll.y;
}
function scroll() {
return {
x: top.window.scrollX || top.window.pageXOffset || top.document.documentElement.scrollLeft || top.document.body.scrollLeft || 0,
y: top.window.scrollY || top.window.pageYOffset || top.document.documentElement.scrollTop || top.document.body.scrollTop || 0
};
};
console.log(x);
console.log(y);
};