--- title: MouseEvent.offsetX slug: Web/API/MouseEvent/offsetX tags: - API - 只读 - 属性 - 鼠标事件 translation_of: Web/API/MouseEvent/offsetX ---
{{APIRef("DOM Events")}}{{SeeCompatTable}}
{{domxref("MouseEvent")}} 接口的只读属性 offsetX 规定了事件对象与目标节点的内填充边(padding edge)在 X 轴方向上的偏移量。
var xOffset = instanceOfMouseEvent.offsetX;
一个双精度
浮点值。早期的规范将其规定为整数值。详见浏览器兼容性部分。
Specification | Status | Comment |
---|---|---|
{{SpecName('CSSOM View', '#dom-mouseevent-offsetx', 'MouseEvent')}} | {{Spec2('CSSOM View')}} | Initial definition |
{{ CompatibilityTable() }}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("39.0")}} | 6 | {{ CompatVersionUnknown() }} | {{ CompatVersionUnknown() }} |
Redefined from long to double |
{{CompatChrome(56)}} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} |
Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile("43.0")}} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} |
Redefined from long to double |
{{CompatChrome(56)}} | {{CompatChrome(56)}} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} |