DOMRect.DOMRect()
Experimental: 这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。
DOMRect()
构造函数生成一个新的 DOMRect
对象。
语法
var myDOMRect = new DOMRect(x, y, width, height);
参数
- x
-
DOMRect
原点的x
坐标。 - y
-
DOMRect
原点的 y 坐标。 - width
-
DOMRect
的宽度。 - height
-
DOMRect
的高度。
例子
想生成一个新 DOMRect
,你可以运行一行这样的代码:
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 |
浏览器兼容性
BCD tables only load in the browser