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 YesEdge Full support 79
Full support 79
Full support 12
Alternate Name
Alternate Name Uses the non-standard name: ClientRect
Firefox Full support YesIE No support No
No support No
Full support Yes
Alternate Name
Alternate Name Uses the non-standard name: ClientRect
Opera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
DOMRectReadOnly() constructorChrome Full support YesEdge Full support 79Firefox Full support YesIE No support NoOpera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
bottomChrome Full support YesEdge Full support 79Firefox Full support YesIE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
fromRect() static functionChrome Full support 57Edge Full support 79Firefox Full support 69IE No support NoOpera Full support 44Safari Full support 10.1WebView Android Full support 57Chrome Android Full support 57Firefox Android No support NoOpera Android Full support 43Safari iOS Full support 10.3Samsung Internet Android Full support 7.0
heightChrome Full support YesEdge Full support 79Firefox Full support YesIE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
leftChrome Full support YesEdge Full support 79Firefox Full support YesIE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
rightChrome Full support YesEdge Full support 79Firefox Full support YesIE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
topChrome Full support YesEdge Full support 79Firefox Full support YesIE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
widthChrome Full support YesEdge Full support 79Firefox Full support YesIE No support No
Notes
No support No
Notes
Notes Implemented on the proprietary ClientRect interface.
Opera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
Available in workersChrome Full support 58Edge Full support 79Firefox Full support 69IE No support NoOpera Full support 45Safari Full support 10.1WebView Android Full support 58Chrome Android Full support 58Firefox Android No support NoOpera Android Full support 43Safari iOS Full support 10.3Samsung Internet Android Full support 7.0
xChrome Full support YesEdge Full support 79Firefox Full support YesIE No support NoOpera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes
yChrome Full support YesEdge Full support 79Firefox Full support YesIE No support NoOpera Full support YesSafari Full support 10.1WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support 10.3Samsung Internet Android Full support Yes

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.

其他