Partager via


Sys.UI.DomElement getLocation Method

Gets the absolute position of a DOM element relative to the upper-left corner of the owner frame or window. This member is static and can be invoked without creating an instance of the class.

var j = Sys.UI.DomElement.getLocation(element);
var x = j.x;
var y = j.y;

Parameters

Term

Definition

element

The target element.

Return Value

An object of the JavaScript type Object that contains the x-coordinate and y-coordinate of the element in pixels.

Remarks

The getLocation method returns an object of the JavaScript type Object that contains the fields listed in the following table.

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.

Note

The getLocation method is not supported for elements that have fixed positioning (style="position:fixed"). In some browsers, getLocation might return incorrect coordinates for elements that have this setting.

Example

The following example shows how to use the getLocation method. This code is part of a larger example found in the Sys.UI.DomElement class overview.

// Get the location of the element
var elementLoc = Sys.UI.DomElement.getLocation(elementRef);
// Get the location of the element
var elementLoc = Sys.UI.DomElement.getLocation(elementRef);

See Also

Reference

Sys.UI.DomElement Class

Other Resources

Language Reference