DOMRectReadOnly

DOMRectReadOnly 接口通过详细列出 DOMRect 所使用的标准属性来定义一个属性不可变的矩形。

构造函数

DOMRectReadOnly()
用来创建新的 DOMRectReadOnly 对象,但请注意,该构造函数不能由第三方 JavaScript 调用:这样做将返回 “Illegal constructor” 类型错误。

属性

DOMRectReadOnly.x 只读
DOMRect 原点的 x 坐标。
DOMRectReadOnly.y 只读
DOMRect 原点的 y 坐标。
DOMRectReadOnly.width 只读
DOMRect 的宽度。
DOMRectReadOnly.height 只读
DOMRect 的高度。
DOMRectReadOnly.top 只读
返回 DOMRect 的顶部坐标值(通常与 y 相同)。
DOMRectReadOnly.right 只读
返回 DOMRect 的右坐标值(通常与 x + width 相同)。
DOMRectReadOnly.bottom 只读
返回 DOMRect 的底部坐标值(通常与 y + height 相同)。
DOMRectReadOnly.left 只读
返回 DOMRect 的左坐标值(通常与 x​​​​​​​ 相同)。

静态方法

DOMRectReadOnly.fromRect()
使用指定的位置和尺寸创建一个新的 DOMRect 对象。

规范

Specification Status Comment
Geometry Interfaces Module Level 1
DOMRectReadOnly
Candidate Recommendation Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
DOMRectReadOnlyChrome Full support 61Edge Full support 79
Full support 79
Full support 12
Alternate Name
Alternate Name Uses the non-standard name: ClientRect
Firefox Full support 31IE No support No
No support No
Full support Yes
Alternate Name
Alternate Name Uses the non-standard name: ClientRect
Opera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 31Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
DOMRectReadOnly() constructorChrome Full support 61Edge Full support 79Firefox Full support 62IE No support NoOpera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 62Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
bottomChrome Full support 61Edge Full support 79Firefox Full support 31IE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 31Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
fromRect() static functionChrome Full support 61Edge Full support 79Firefox Full support 69IE No support NoOpera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android No support NoOpera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
heightChrome Full support 61Edge Full support 79Firefox Full support 31IE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 31Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
leftChrome Full support 61Edge Full support 79Firefox Full support 31IE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 31Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
rightChrome Full support 61Edge Full support 79Firefox Full support 31IE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 31Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
topChrome Full support 61Edge Full support 79Firefox Full support 31IE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 31Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
widthChrome Full support 61Edge Full support 79Firefox Full support 31IE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 31Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
Available in workersChrome Full support 61Edge Full support 79Firefox Full support 69IE No support NoOpera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android No support NoOpera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
xChrome Full support 61Edge Full support 79Firefox Full support 31IE No support NoOpera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 31Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0
yChrome Full support 61Edge Full support 79Firefox Full support 31IE No support NoOpera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 31Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.
Uses a non-standard name.
Uses a non-standard name.

其他