Sys.UI.DomElement getBounds Method
Gets a set of integer coordinates that represent the position, width, and height of a DOM element. This member is static and can be invoked without creating an instance of the class.
Syntax
var b = Sys.UI.DomElement.getBounds(element);
var x = b.x;
var y = b.y;
var w = b.width;
var h = b.height;
Return Value
A JSON-formatted object that contains the x-coordinate and y-coordinate of the upper-left corner, the width, and the height of the element in pixels.
Remarks
The JSON object that is returned by the getBounds method contains the following four fields:
|
Field
|
Definition
|
|
x
|
The number of pixels between the element and the left edge of the owner frame or window.
|
|
y
|
The number of pixels between the element and the top edge of the owner frame or window.
|
|
width
|
The width of the element in pixels.
|
|
height
|
The height of the element in pixels.
|
Example
The following example shows how to use the getBounds method. This code is part of a larger example found in the Sys.UI.DomElement class overview.
cs
// Get the bounds of the element
var elementRef = $get("Label1");
var elementBounds = Sys.UI.DomElement.getBounds(elementRef);
vb
// Get the bounds of the element
var elementRef = $get("Label1");
var elementBounds = Sys.UI.DomElement.getBounds(elementRef);