Geometry Interfaces
The DOMRectReadOnly() constructor creates a new DOMRectReadOnly object.
Syntax
new DOMRectReadOnly(x, y, width, height)
Parameters
x- : The
xcoordinate of theDOMRectReadOnly's origin.
- : The
y- : The
ycoordinate of theDOMRectReadOnly's origin.
- : The
width- : The width of the
DOMRectReadOnly.
- : The width of the
height- : The height of the
DOMRectReadOnly.
- : The height of the
Examples
To create a new DOMRectReadOnly, you could run a line of code like so:
const myDOMRect = new DOMRectReadOnly(0, 0, 100, 100);
// running 'myDOMRect' in the console would then return
// DOMRectReadOnly { x: 0, y: 0, width: 100, height: 100, top: 0, right: 100, bottom: 100, left: 0 }
Specifications
Browser compatibility
See also
- DOMPoint
- DOMRect
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
