The DOMRectReadOnly
interface specifies the standard properties used by DOMRect
to define a rectangle whose properties are immutable.
Constructor
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
.
Properties
DOMRectReadOnly.x
Read only- The x coordinate of the
DOMRect
's origin. DOMRectReadOnly.y
Read only- The y coordinate of the
DOMRect
's origin. DOMRectReadOnly.width
Read only- The width of the
DOMRect
. DOMRectReadOnly.height
Read only- The height of the
DOMRect
. DOMRectReadOnly.top
Read only- Returns the top coordinate value of the
DOMRect
(usually the same asy
.) DOMRectReadOnly.right
Read only- Returns the right coordinate value of the
DOMRect
(usually the same asx + width
). DOMRectReadOnly.bottom
Read only- Returns the bottom coordinate value of the
DOMRect
(usually the same asy + height
). DOMRectReadOnly.left
Read only- Returns the left coordinate value of the
DOMRect
(usually the same asx
).
Static methods
DOMRectReadOnly.fromRect()
- Creates a new
DOMRect
object with a given location and dimensions.
Specifications
Specification | Status | Comment |
---|---|---|
Geometry Interfaces Module Level 1 The definition of 'DOMRectReadOnly' in that specification. |
Candidate Recommendation | Initial definition. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
DOMRectReadOnly | Chrome Full support Yes | Edge
Full support
79
| Firefox Full support Yes | IE
No support
No
| Opera Full support Yes | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support 10.3 | Samsung Internet Android Full support Yes |
DOMRectReadOnly() constructor | Chrome Full support Yes | Edge Full support 79 | Firefox Full support Yes | IE No support No | Opera Full support Yes | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support 10.3 | Samsung Internet Android Full support Yes |
bottom | Chrome Full support Yes | Edge Full support 79 | Firefox Full support Yes | IE
No support
No
| Opera Full support Yes | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support 10.3 | Samsung Internet Android Full support Yes |
fromRect() static function | Chrome Full support 57 | Edge Full support 79 | Firefox Full support 69 | IE No support No | Opera Full support 44 | Safari Full support 10.1 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android No support No | Opera Android Full support 43 | Safari iOS Full support 10.3 | Samsung Internet Android Full support 7.0 |
height | Chrome Full support Yes | Edge Full support 79 | Firefox Full support Yes | IE
No support
No
| Opera Full support Yes | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support 10.3 | Samsung Internet Android Full support Yes |
left | Chrome Full support Yes | Edge Full support 79 | Firefox Full support Yes | IE
No support
No
| Opera Full support Yes | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support 10.3 | Samsung Internet Android Full support Yes |
right | Chrome Full support Yes | Edge Full support 79 | Firefox Full support Yes | IE
No support
No
| Opera Full support Yes | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support 10.3 | Samsung Internet Android Full support Yes |
top | Chrome Full support Yes | Edge Full support 79 | Firefox Full support Yes | IE
No support
No
| Opera Full support Yes | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support 10.3 | Samsung Internet Android Full support Yes |
width | Chrome Full support Yes | Edge Full support 79 | Firefox Full support Yes | IE
No support
No
| Opera Full support Yes | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support 10.3 | Samsung Internet Android Full support Yes |
Available in workers | Chrome Full support 58 | Edge Full support 79 | Firefox Full support 69 | IE No support No | Opera Full support 45 | Safari Full support 10.1 | WebView Android Full support 58 | Chrome Android Full support 58 | Firefox Android No support No | Opera Android Full support 43 | Safari iOS Full support 10.3 | Samsung Internet Android Full support 7.0 |
x | Chrome Full support Yes | Edge Full support 79 | Firefox Full support Yes | IE No support No | Opera Full support Yes | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support 10.3 | Samsung Internet Android Full support Yes |
y | Chrome Full support Yes | Edge Full support 79 | Firefox Full support Yes | IE No support No | Opera Full support Yes | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support 10.3 | Samsung 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.