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.

var b = Sys.UI.DomElement.getBounds(element);
var x = b.x;
var y = b.y;
var w = b.width;
var h = b.height;

Parameters

Term

Definition

element

The Sys.UI.DomElement instance to get the coordinates of.

Return Value

An object of the JavaScript type 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 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.

// Get the bounds of the element
var elementRef = $get("Label1");
var elementBounds = Sys.UI.DomElement.getBounds(elementRef);
// Get the bounds of the element
var elementRef = $get("Label1");
var elementBounds = Sys.UI.DomElement.getBounds(elementRef);

See Also

Reference

Sys.UI.DomElement Class

Other Resources

Language Reference