DOMRect.DOMRect()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年1月.
DOMRect() 构造函数生成一个新的 DOMRect 对象。
语法
js
var myDOMRect = new DOMRect(x, y, width, height);
参数
例子
想生成一个新 DOMRect,你可以运行一行这样的代码:
js
myDOMRect = new DOMRect(0, 0, 100, 100);
// running 'myDOMRect' in the console would then return
// DOMRect { x: 0, y: 0, width: 100, height: 100, top: 0, right: 100, bottom: 100, left: 0 }
规范
| Specification |
|---|
| Geometry Interfaces Module Level 1> # dom-domrect-domrect> |