Home > Web Front-end > JS Tutorial > body text

JavaScript function to obtain mouse coordinates (compatible with IE, FireFox, Chrome)_javascript skills

WBOY
Release: 2016-05-16 18:36:32
Original
1097 people have browsed it

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:)

Copy code The code is as follows:

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
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!