Js to get precise mouse coordinates

Source: Internet
Author: User
Currently, many website analysis systems need to obtain mouse coordinates and tracks to draw cloud maps and mouse tracks, which requires that the mouse coordinates must be accurate. But it is difficult to be accurate. For example, when a user opens the Baidu homepage and clicks the website font in different browser sizes, the coordinates are completely inconsistent... SyntaxHighlighter. all ();

Currently, many website analysis systems need to obtain mouse coordinates and tracks to draw cloud maps and mouse tracks, which requires that the mouse coordinates must be accurate. But it is difficult to be accurate.
For example:
The user opens the Baidu homepage and clicks the "website" font in different browser sizes. The coordinates are completely different. Why are the coordinates inaccurate, cloud maps, and hotspot maps accurate?
There are three uncertainties about a common website:
1. fixed width?
2. Whether to Lean to the left, right, and center
3. Adaptive size?
 
These three uncertainties cannot be obtained through js, so the specific values of these three parameters must be notified through the website.
Purpose: no matter the browser window size, the mouse clicking coordinates are exactly the same as those when the browser is maximized.
 
Coordinate offset generally does not take the Y axis coordinates into account, so the code is only applicable to the X axis.
Js Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.