DOMRectReadOnly

DOMRectReadOnly interface specifies the standard properties used by DOMRect to define a rectangle whose properties are immutable.

构造函数

DOMRectReadOnly()
Defined to create a new DOMRectReadOnly object. Note that this constructor cannot be called by 3rd party JavaScript; doing so returns an "Illegal constructor" TypeError .

特性

DOMRectReadOnly.x 只读
The x coordinate of the DOMRect 's origin.
DOMRectReadOnly.y 只读
The y coordinate of the DOMRect 's origin.
DOMRectReadOnly.width 只读
The width of the DOMRect .
DOMRectReadOnly.height 只读
The height of the DOMRect .
DOMRectReadOnly.top 只读
Returns the top coordinate value of the DOMRect (usually the same as y .)
DOMRectReadOnly.right 只读
Returns the right coordinate value of the DOMRect (usually the same as x + width ).
DOMRectReadOnly.bottom 只读
Returns the bottom coordinate value of the DOMRect (usually the same as y + height ).
DOMRectReadOnly.left 只读
Returns the left coordinate value of the DOMRect (usually the same as x ).

静态方法

DOMRectReadOnly.fromRect()
创建新的 DOMRect object with a given location and dimensions.

规范

规范 状态 Comment
Geometry Interfaces Module Level 1
The definition of 'DOMRectReadOnly' in that specification.
候选推荐 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
DOMRectReadOnly Chrome Yes Edge 79
79
12
Alternate Name
Alternate Name Uses the non-standard name: ClientRect
Firefox Yes IE 不支持 No
No
Yes
Alternate Name
Alternate Name Uses the non-standard name: ClientRect
Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
DOMRectReadOnly() 构造函数 Chrome Yes Edge 79 Firefox Yes IE 不支持 No Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
bottom Chrome Yes Edge 79 Firefox Yes IE 不支持 No
注意事项
No
注意事项
Implemented on the proprietary ClientRect 接口。
Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
fromRect() static function Chrome 57 Edge 79 Firefox 69 IE 不支持 No Opera 44 Safari 10.1 WebView Android 57 Chrome Android 57 Firefox Android 不支持 No Opera Android 43 Safari iOS 10.3 Samsung Internet Android 7.0
height Chrome Yes Edge 79 Firefox Yes IE 不支持 No
注意事项
No
注意事项
Implemented on the proprietary ClientRect 接口。
Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
left Chrome Yes Edge 79 Firefox Yes IE 不支持 No
注意事项
No
注意事项
Implemented on the proprietary ClientRect 接口。
Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
right Chrome Yes Edge 79 Firefox Yes IE 不支持 No
注意事项
No
注意事项
Implemented on the proprietary ClientRect 接口。
Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
top Chrome Yes Edge 79 Firefox Yes IE 不支持 No
注意事项
No
注意事项
Implemented on the proprietary ClientRect 接口。
Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
width Chrome Yes Edge 79 Firefox Yes IE 不支持 No
注意事项
No
注意事项
Implemented on the proprietary ClientRect 接口。
Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
Available in workers Chrome 58 Edge 79 Firefox 69 IE 不支持 No Opera 45 Safari 10.1 WebView Android 58 Chrome Android 58 Firefox Android 不支持 No Opera Android 43 Safari iOS 10.3 Samsung Internet Android 7.0
x Chrome Yes Edge 79 Firefox Yes IE 不支持 No Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes
y Chrome Yes Edge 79 Firefox Yes IE 不支持 No Opera Yes Safari 10.1 WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS 10.3 Samsung Internet Android Yes

图例

完整支持
完整支持
不支持
不支持
见实现注意事项。
使用非标名称。
使用非标名称。

另请参阅