Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

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.

Syntax

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

Term

Definition

element

The target element.

Return Value

A JSON-formatted object that contains the x-coordinate and y-coordinate of the element in pixels.

Remarks

The getLocation method returns a JSON 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.

cs

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

vb

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