Mouse pointer location resolution and compatibility method

Source: Internet
Author: User

Getting the position of the mouse pointer is an important event when an event occurs. This was originally a very simple question, but due to the browser's incompatibility, the development brought challenges. Different browsers define different attributes in their respective event objects, as described in the chart below.

Property Description Compatibility
ClientX Position x-axis coordinates with the top-left corner of the browser window as the origin point All browsers, not compatible with Safari
ClientY Position y-axis coordinates with the upper-left corner of the browser window as the origin point All browsers, not compatible with Safari
OffsetX Position x-axis coordinates with the top-left corner of the target object of the current event as the origin point All browsers, not compatible with Mozilla
OffsetY Positions the y-axis coordinates with the top-left corner of the target object of the current event as the origin point All browsers, not compatible with Mozilla
PageX Position x-axis coordinates with the top-left corner of the document object (that is, the Documents window). All browsers, not compatible with IE
Pagey Position the y-axis coordinates with the top-left corner of the document object (that is, the Documents window). All browsers, not compatible with IE
ScreenX The upper-left corner of the computer screen is the origin and the x-axis coordinates are located . All browsers
screeny computer screen the upper-left corner is the origin. , positioning y-axis coordinates All browsers
layerx (if not, the Document object) the upper-left corner is the origin, positioning x-axis coordinates mozilla and Safari
Layery nearest absolute position parent element (or Document object if not) the upper-left corner is the origin, and the y-axis coordinates are positioned Mozilla and Safari

Mouse pointer location resolution and compatibility method

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.