Fortunately, everything is available on the Internet. I found a function with the best browser compatibility online. It has been tested to be compatible with IE, FireFox, and Chrome, and there is no scroll bar error problem. Save it for future use:)
function mousePos(e){
var x,y;
var e = e||window.event;
return {
x:e.clientX document.body.scrollLeft document.documentElement.scrollLeft,
y:e.clientY document.body.scrollTop document .documentElement.scrollTop
};
}
Note: This function is used in conjunction with the onmousemove event.
Function source: mouse follow prompt box by nunumick